nim-lang/nimsuggest

nimsuggest SIGSEGV when passing some unknown files

timotheecour opened this issue · 8 comments

/cc @Araq
now that nim-lang/Nim#9757 was merged, the caveats I had mentioned in that PR hold:

nimsuggest --stdin /Users/timothee/git_clone/nim/Nim/lib/system.nim
def /Users/timothee/git_clone/nim/Nim/lib/system.nim:106:22
def /Users/timothee/git_clone/nim/Nim/compiler/modules.nim:69:63
gives SIGSEGV
see stacktrace here:
nim-lang/Nim#9715 (comment)

@timotheecour Here's the nimsuggest bug tracker: https://github.com/nim-lang/nimsuggest. I'd recommend migrating this issue there.

nc-x commented

Can't reproduce for system.nim

And the line 69 in modules.nim has changed now and the line at the time this issue was opened (https://github.com/timotheecour/Nim/blob/1c71b0be2ffa378945c61927d9351b88b5033b08/compiler/modules.nim#L69) does not exist anymore.

Can't reproduce for system.nim

no, def /Users/timothee/git_clone/nim/Nim/lib/system.nim:106:22 worked, since that file is given on cmd line that starts nimsuggest

And the line 69 in modules.nim has changed now and the line at the time this issue was opened

regardless, it still SIGSEGV's:
on latest devel:
git rev-parse HEAD
513a287c61e6e461b013e75a7f5dbfa0136b606c

nimsuggest --stdin /Users/timothee/git_clone/nim/Nim/lib/system.nim
Hint: used config file '/Users/timothee/git_clone/nim/Nim/config/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/.config/nim/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/git_clone/nim/Nim/config/config.nims' [Conf]
usage: sug|con|def|use|dus|chk|mod|highlight|outline|known file.nim[;dirtyfile.nim]:line:col
type 'quit' to quit
type 'debug' to toggle debug mode on/off
type 'terse' to toggle terse mode on/off
> def /Users/timothee/git_clone/nim/Nim/lib/system.nim:106:22
def     skType  system.SomeInteger      SomeInteger     /Users/timothee/git_clone/nim/Nim/lib/system.nim        96      2       "type class matching all integer types" 100

> def /Users/timothee/git_clone/nim/Nim/compiler/modules.nim:69:63
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

nc-x commented

No crash if def /Users/timothee/git_clone/nim/Nim/lib/system.nim:106:22 is not executed first.
Otherwise (nimsuggest compiled in debug mode) -

> def lib/system.nim:106:22
def     skType  system.SomeInteger      SomeInteger     C:\Nim\lib\sys
        96      2       "type class matching all integer types" 100

> def compiler/modules.nim:69:40
nimsuggest.nim(622)      nimsuggest
nimsuggest.nim(619)      handleCmdLine
cmdlinehelper.nim(92)    loadConfigsAndRunMainCommand
nimsuggest.nim(531)      mainCommand
nimsuggest.nim(479)      mainThread
nimsuggest.nim(445)      execCmd
nimsuggest.nim(209)      execute
nimsuggest.nim(183)      executeNoHooks
modules.nim(134)         compileProject
modules.nim(79)          compileModule
passes.nim(197)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(609)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(200)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(609)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(197)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(609)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(200)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(609)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(197)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(609)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(197)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(609)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2602)       semExpr
importer.nim(212)        evalImport
importer.nim(182)        impMod
importer.nim(154)        myImportModule
modules.nim(92)          importModule
modules.nim(79)          compileModule
passes.nim(194)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(609)             myProcess
sem.nim(572)             semStmtAndGenerateGenerics
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2569)       semExpr
semstmts.nim(1988)       semStmtList
semexprs.nim(2611)       semExpr
semstmts.nim(1912)       evalInclude
semstmts.nim(1892)       incMod
semstmts.nim(2048)       semStmt
semexprs.nim(915)        semExprNoType
semexprs.nim(2569)       semExpr
semstmts.nim(1988)       semStmtList
semexprs.nim(2493)       semExpr
semexprs.nim(2124)       semWhen
sem.nim(354)             semConstExpr
vm.nim(1894)             evalConstExpr
vm.nim(1890)             evalConstExprAux
vm.nim(1541)             rawExecute
system.nim(2985)         sysFatal
Error: unhandled exception: node is not accessible [FieldError]

@krux02 I see you transferred the issue to here, thanks! is there any way to transfer the set of all labels too? (i know, some may not be relevant, but may be simpler to reuse same labels)

nimsuggest --debug --log . crashes with SIGSEGV: Illegal storage access. (Attempt to read from nil?) from a build from the current Nim devel repo

saem commented

Is this still a bug because I can't seem to replciate it?

if, fixed, please add a regression test case in a PR before closing this issue, thanks!

(the test case obviously should be such that it would fail using an older nim, eg the one right after nim-lang/Nim#9757)