Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nimsuggest crash #17437

Closed
StefanSalewski opened this issue Mar 21, 2021 · 1 comment · Fixed by #17547
Closed

Nimsuggest crash #17437

StefanSalewski opened this issue Mar 21, 2021 · 1 comment · Fixed by #17547

Comments

@StefanSalewski
Copy link

$ cat t.nim 
type
  V = ref object
    x, y: int

proc m =
  var v = V(x: x, y)

m()
$ nimsuggest t.nim 
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)
nim check t.nim 
Hint: used config file '/home/salewski/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/salewski/Nim/config/config.nims' [Conf]
....
/tmp/hhh/t.nim(6, 16) Error: undeclared identifier: 'x'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (1, 2): 'V' [type declared in /tmp/hhh/t.nim(2, 3)]
 (1, 2): 'm' [proc declared in /tmp/hhh/t.nim(5, 6)]
 (1, 3): 't' [module declared in /tmp/hhh/t.nim(1, 2)]
 (1, 4): '$' [proc declared in /home/salewski/Nim/lib/system/dollars.nim(1, 6)]
/tmp/hhh/t.nim(6, 16) Error: expression 'x' has no type (or is ambiguous)
/tmp/hhh/t.nim(6, 19) Error: incorrect object construction syntax
/tmp/hhh/t.nim(6, 19) Error: incorrect object construction syntax
/tmp/hhh/t.nim(6, 7) Hint: 'v' is declared but not used [XDeclaredButNotUsed]
fatal.nim(53)            sysFatal
Error: unhandled exception: 'sons' is not accessible using discriminant 'kind' of type 'TNode' [FieldDefect]
nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-03-19
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 83e002a318dee2370b266446d5ec26ad97a65f57
active boot switches: -d:release
saem added a commit to saem/Nim that referenced this issue Mar 28, 2021
Araq pushed a commit that referenced this issue Mar 29, 2021
* fixes #17437

* Fix bug reference comment

Co-authored-by: Timothee Cour <[email protected]>

* [skip ci] describe why we have hasError

Co-authored-by: Timothee Cour <[email protected]>
@StefanSalewski
Copy link
Author

Thanks for trying to fix...

While nim check works fine now, nimsuggest unfortunately still crashes when one tries to fill in the values of an object constructor as in

$ cat t.nim 
proc prepare_and_insert_input_data_for_finding_hull_to_stack(
    disks: ListCircularDisk2D; preApexDisk: CircularDisk2D;
    postApexDisk: CircularDisk2D; hullPointOfPreApexDisk: Point2D;
    hullPointOfPostApexDisk: Point2D; stackForFindingHull: StackInputForFindHull) =
    var inputForFindHull = InputForFindHull(disks: disks, preApexDisk, postApexDisk, hullPointOfPreApexDisk, hullPointOfPostApexDisk)
    
salewski@nuc ~/quickhulldisk $ nimsuggest t.nim 
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Segmentation fault (core dumped)
salewski@nuc ~/quickhulldisk $ nim check t.nim 
Hint: used config file '/home/salewski/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/salewski/Nim/config/config.nims' [Conf]
....
/home/salewski/quickhulldisk/t.nim(2, 12) Error: undeclared identifier: 'ListCircularDisk2D'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (13, 3): 'LibraryError' [type declared in /home/salewski/Nim/lib/system/exceptions.nim(66, 3)]
 (13, 3): 'cstringArray' [type declared in /home/salewski/Nim/lib/system.nim(1448, 3)]
 (13, 3): 'declared' [proc declared in /home/salewski/Nim/lib/system.nim(169, 8)]
 (13, 3): 'gcInvariant' [proc declared in /home/salewski/Nim/lib/system/gc.nim(437, 6)]
 (13, 3): 'iterators' [module declared in /home/salewski/Nim/lib/system/iterators.nim(1, 2)]
 (13, 3): 'nimCoroutines' [const declared in /home/salewski/Nim/lib/system.nim(1928, 9)]
 (13, 3): 'resizeShared' [proc declared in /home/salewski/Nim/lib/system/memalloc.nim(288, 8)]
 (13, 3): 'staticRead' [proc declared in /home/salewski/Nim/lib/system.nim(2646, 6)]
 (13, 3): 'writeChars' [proc declared in /home/salewski/Nim/lib/system/io.nim(214, 6)]
/home/salewski/quickhulldisk/t.nim(2, 45) Error: undeclared identifier: 'CircularDisk2D'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (5, 2): 'ListCircularDisk2D' [unknown declared in /home/salewski/quickhulldisk/t.nim(2, 12)]
 (5, 2): 'ListCircularDisk2D' [unknown declared in /home/salewski/quickhulldisk/t.nim(2, 12)]
/home/salewski/quickhulldisk/t.nim(3, 59) Error: undeclared identifier: 'Point2D'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (3, 3): 'PInt32' [type declared in /home/salewski/Nim/lib/system.nim(1457, 3)]
 (3, 3): 'PInt64' [type declared in /home/salewski/Nim/lib/system.nim(1456, 3)]
 (3, 3): 'pointer' [type declared in /home/salewski/Nim/lib/system.nim(36, 3)]
 (3, 3): 'toInt' [proc declared in /home/salewski/Nim/lib/system.nim(1477, 6)]
/home/salewski/quickhulldisk/t.nim(4, 60) Error: undeclared identifier: 'StackInputForFindHull'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (14, 3): 'StackTraceEntry' [type declared in /home/salewski/Nim/lib/system/exceptions.nim(17, 3)]
/home/salewski/quickhulldisk/t.nim(5, 28) Error: undeclared identifier: 'InputForFindHull'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (6, 3): 'StackInputForFindHull' [unknown declared in /home/salewski/quickhulldisk/t.nim(4, 60)]
 (6, 3): 'StackInputForFindHull' [unknown declared in /home/salewski/quickhulldisk/t.nim(4, 60)]
/home/salewski/quickhulldisk/t.nim(5, 44) Error: object constructor needs an object type
/home/salewski/quickhulldisk/t.nim(5, 44) Error: expression '' has no type (or is ambiguous)
/home/salewski/quickhulldisk/t.nim(5, 9) Hint: 'inputForFindHull' is declared but not used [XDeclaredButNotUsed]
/home/salewski/quickhulldisk/t.nim(1, 6) Hint: 'prepare_and_insert_input_data_for_finding_hull_to_stack' is declared but not used [XDeclaredButNotUsed]
salewski@nuc ~/quickhulldisk $ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-03-30
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 9e88425d7c5e3edfcbddedbe062c5f028789a002
active boot switches: -d:release

Not that example is an actual use case, not invalid Ruby or C++ code. The Object I try to fill is

type
  InputForFindHull* = object # {.bycopy.} = object
    disks*: ListCircularDisk2D
    preApexDisk*: CircularDisk2D
    postApexDisk*: CircularDisk2D
    hullPointOfPreApexDisk*: Point2D
    hullPointOfPostApexDisk*: Point2D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant