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

[major] SIGSEGV: Illegal storage access in gen=>genCall=>skipTypes #93

Closed
timotheecour opened this issue Nov 3, 2018 · 11 comments
Closed

Comments

@timotheecour
Copy link
Member

/cc @Araq

include sequtils
# import sequtils


echo 1
echo "sug bugs/nimsuggest/t01.nim:5:3" | nimsuggest --stdin bugs/nimsuggest/t01.nim

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
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
@timotheecour timotheecour changed the title SIGSEGV: Illegal storage access with include sequtils [major] SIGSEGV: Illegal storage access with include sequtils Nov 3, 2018
@timotheecour
Copy link
Member Author

after compiling a debug version of nimsuggest as follows:

bin/nim c --noNimblePath -p:compiler --debugger:native -o:bin/nimsuggest_dbg nimsuggest/nimsuggest.nim

and running

echo "sug bugs/nimsuggest/t01.nim:5:3" | $nimc_D/bin/nimsuggest_dbg --stdin bugs/nimsuggest/t01.nim

I'm getting:

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
Traceback (most recent call last)
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(616) nimsuggest
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(614) handleCmdLine
/Users/timothee/git_clone/nim/Nim/compiler/cmdlinehelper.nim(91) loadConfigsAndRunMainCommand
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(526) mainCommand
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(474) mainThread
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(440) execCmd
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(198) execute
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(126) compileProject
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(78) compileModule
/Users/timothee/git_clone/nim/Nim/compiler/passes.nim(194) processModule
/Users/timothee/git_clone/nim/Nim/compiler/passes.nim(86) processTopLevelStmt
/Users/timothee/git_clone/nim/Nim/compiler/sem.nim(605) myProcess
/Users/timothee/git_clone/nim/Nim/compiler/sem.nim(568) semStmtAndGenerateGenerics
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1973) semStmt
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(913) semExprNoType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2534) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1914) semStmtList
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2576) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1835) evalInclude
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1973) semStmt
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(913) semExprNoType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2534) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1914) semStmtList
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2458) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2063) semWhen
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2534) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1914) semStmtList
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2533) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2266) semBlock
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2534) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1914) semStmtList
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2537) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(438) semVarOrLet
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(59) semExprWithType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2422) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(895) semDirectOp
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(788) afterCallActions
/Users/timothee/git_clone/nim/Nim/compiler/sem.nim(463) semMacroExpr
/Users/timothee/git_clone/nim/Nim/compiler/vm.nim(1988) evalMacroCall
/Users/timothee/git_clone/nim/Nim/compiler/vm.nim(1034) rawExecute
/Users/timothee/git_clone/nim/Nim/compiler/vm.nim(396) compile
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(2175) genProc
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(263) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(1985) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(263) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(1964) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(354) genIf
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(258) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(1944) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(525) genCall
/Users/timothee/git_clone/nim/Nim/compiler/ast.nim(1421) skipTypes
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

@timotheecour
Copy link
Member Author

with lldb (see instructions in #94) I'm getting:

(lldb) c
Process 48944 resuming
Process 48944 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
    frame #0: 0x000000010168459e nimsuggest_dbg3 skipTypes_7vZ9a9bub9bucX5E73hsr9cjvg(t=0x0000000000000000, kinds=36099165763184912) + 126 at /Users/timothee/git_clone/nim/Nim/compiler/ast.nim:1421
   1418   ## last child nodes of a type tree need to be searched. This is a really hot
   1419   ## path within the compiler!
   1420   result = t
-> 1421   while result.kind in kinds: result = lastSon(result)
   1422
   1423 proc skipTypes*(t: PType, kinds: TTypeKinds; maxIters: int): PType =
   1424   result = t
Target 0: (nimsuggest_dbg3) stopped.
(lldb)

@timotheecour
Copy link
Member Author

even more info:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
  * frame #0: 0x000000010168459e nimsuggest_dbg3 skipTypes_7vZ9a9bub9bucX5E73hsr9cjvg(t=0x0000000000000000, kinds=36099165763184912) + 126 at /Users/timothee/git_clone/nim/Nim/compiler/ast.nim:1421
    frame #1: 0x00000001019749d1 nimsuggest_dbg3 genCall_AcnszMkIUvrpRfWF4iqy5g_5(c=0x0000000101bcddf0, n=0x0000000102fb4d68, dest=0x00007ffeee6325b8) + 513 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:525
    frame #2: 0x0000000101967e2c nimsuggest_dbg3 gen_6vrKVoM8aZ4Rjealu5DZbw(c=0x0000000101bcddf0, n=0x0000000102fb4d68, dest=0x00007ffeee6325b8, flags='\0') + 3132 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:1944
    frame #3: 0x0000000101972805 nimsuggest_dbg3 gen_KQ9csS06JMUvwHLxUYEy8rA(c=0x0000000101bcddf0, n=0x0000000102fb4d68, dest=5, flags='\0') + 133 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:258
    frame #4: 0x0000000101980cff nimsuggest_dbg3 genIf_AcnszMkIUvrpRfWF4iqy5g_8(c=0x0000000101bcddf0, n=0x0000000102fb4e10, dest=0x00007ffeee632ad0) + 2303 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:354
    frame #5: 0x0000000101968376 nimsuggest_dbg3 gen_6vrKVoM8aZ4Rjealu5DZbw(c=0x0000000101bcddf0, n=0x0000000102fb4e10, dest=0x00007ffeee632ad0, flags='\0') + 4486 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:1964
    frame #6: 0x000000010197b711 nimsuggest_dbg3 gen_M9cKwar4hMj62R1lH9bydpDQ(c=0x0000000101bcddf0, n=0x0000000102fb4e10, flags='\0') + 129 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:263
    frame #7: 0x000000010196883e nimsuggest_dbg3 gen_6vrKVoM8aZ4Rjealu5DZbw(c=0x0000000101bcddf0, n=0x0000000102fb4e48, dest=0x00007ffeee632e20, flags='\0') + 5710 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:1985
    frame #8: 0x000000010197b711 nimsuggest_dbg3 gen_M9cKwar4hMj62R1lH9bydpDQ(c=0x0000000101bcddf0, n=0x0000000102fb4e48, flags='\0') + 129 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:263
    frame #9: 0x000000010198c510 nimsuggest_dbg3 genProc_82SK3f7Ee6e9aktSfHKYXUw(c=0x0000000101bcddf0, s=0x00000001024125c0) + 3264 at /Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim:2175
    frame #10: 0x00000001018c2188 nimsuggest_dbg3 compile_wk4OXe22qII4FFHuYMKF5Q(c=0x0000000101bcddf0, s=0x00000001024125c0) + 104 at /Users/timothee/git_clone/nim/Nim/compiler/vm.nim:396
    frame #11: 0x00000001018eb4fe nimsuggest_dbg3 rawExecute_k9aCKiABulyArsh8tgO9aNnQ(c=0x0000000101bcddf0, start=1460, tos=0x0000000102fb5860, Result=0x00007ffeee6395e8) + 151902 at /Users/timothee/git_clone/nim/Nim/compiler/vm.nim:1034
    frame #12: 0x00000001019110b3 nimsuggest_dbg3 evalMacroCall_wCEfcY0TEZRJihtTHLABDg(module=0x0000000102734750, g=0x0000000101bbd048, n=0x0000000102fb6550, nOrig=0x0000000102fb6748, sym=0x000000010240d8e0) + 4963 at /Users/timothee/git_clone/nim/Nim/compiler/vm.nim:1988
    frame #13: 0x00000001017d4d78 nimsuggest_dbg3 semMacroExpr_GFpnqBAgGBu4p8rc0WsOTw(c=0x0000000102934048, n=0x0000000102fb6550, nOrig=0x0000000102fb6748, sym=0x000000010240d8e0, flags=3072) + 968 at /Users/timothee/git_clone/nim/Nim/compiler/sem.nim:463
    frame #14: 0x000000010181000d nimsuggest_dbg3 afterCallActions_Qn3T9bt6Cg4I7XaYRMg219aw(c=0x0000000102934048, n=0x0000000102fb6550, orig=0x0000000102fb6748, flags=3072) + 509 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:788
    frame #15: 0x0000000101805e23 nimsuggest_dbg3 semDirectOp_vJZwz9bfROKrfrtM50y74CQ_5(c=0x0000000102934048, n=0x00000001021d5860, flags=3072) + 243 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:895
    frame #16: 0x00000001017b8c3a nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x00000001021d5860, flags=3072) + 4170 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2422
    frame #17: 0x00000001017bbb34 nimsuggest_dbg3 semExprWithType_vJZwz9bfROKrfrtM50y74CQ(c=0x0000000102934048, n=0x00000001021d5860, flags=1024) + 116 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:59
    frame #18: 0x0000000101866973 nimsuggest_dbg3 semVarOrLet_9aaeuZC3SovMoEd6yN1pUdg(c=0x0000000102934048, n=0x00000001021d5dd8, symkind='\t') + 2147 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:438
    frame #19: 0x00000001017ba4a1 nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x00000001021d5dd8, flags=0) + 10417 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2537
    frame #20: 0x00000001018621a5 nimsuggest_dbg3 semStmtList_vJZwz9bfROKrfrtM50y74CQ_28(c=0x0000000102934048, n=0x00000001021d5e10, flags=0) + 661 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1914
    frame #21: 0x00000001017ba41c nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x00000001021d5e10, flags=0) + 10284 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2534
    frame #22: 0x0000000101861b0b nimsuggest_dbg3 semBlock_vJZwz9bfROKrfrtM50y74CQ_27(c=0x0000000102934048, n=0x00000001021d5e48, flags=0) + 1947 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2266
    frame #23: 0x00000001017ba3f0 nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x00000001021d5e48, flags=0) + 10240 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2533
    frame #24: 0x00000001018621a5 nimsuggest_dbg3 semStmtList_vJZwz9bfROKrfrtM50y74CQ_28(c=0x0000000102934048, n=0x000000010240cc50, flags=0) + 661 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1914
    frame #25: 0x00000001017ba41c nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x000000010240cc50, flags=0) + 10284 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2534
    frame #26: 0x0000000101822390 nimsuggest_dbg3 semWhen_5C4HPXQuhxlMYIzPbe36lg(c=0x0000000102934048, n=0x000000010240ccf8, semCheck='\x01') + 3680 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2063
    frame #27: 0x00000001017b9533 nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x000000010240ccf8, flags=64) + 6467 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2458
    frame #28: 0x00000001018621a5 nimsuggest_dbg3 semStmtList_vJZwz9bfROKrfrtM50y74CQ_28(c=0x0000000102934048, n=0x00000001024a1c88, flags=64) + 661 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1914
    frame #29: 0x00000001017ba41c nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x00000001024a1c88, flags=64) + 10284 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2534
    frame #30: 0x00000001017b7b78 nimsuggest_dbg3 semExprNoType_7YxUILpPxooC5qqa89a54dw_2(c=0x0000000102934048, n=0x00000001024a1c88) + 248 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:913
    frame #31: 0x00000001017bb855 nimsuggest_dbg3 semStmt_vJZwz9bfROKrfrtM50y74CQ_3(c=0x0000000102934048, n=0x00000001024a1c88, flags=0) + 165 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1973
    frame #32: 0x00000001018850d1 nimsuggest_dbg3 evalInclude_7YxUILpPxooC5qqa89a54dw_57(c=0x0000000102934048, n=0x00000001024a1e80) + 1217 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1835
    frame #33: 0x00000001017baa5d nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x00000001024a1e80, flags=64) + 11885 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2576
    frame #34: 0x00000001018621a5 nimsuggest_dbg3 semStmtList_vJZwz9bfROKrfrtM50y74CQ_28(c=0x0000000102934048, n=0x00000001024a1e10, flags=64) + 661 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1914
    frame #35: 0x00000001017ba41c nimsuggest_dbg3 semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000102934048, n=0x00000001024a1e10, flags=64) + 10284 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2534
    frame #36: 0x00000001017b7b78 nimsuggest_dbg3 semExprNoType_7YxUILpPxooC5qqa89a54dw_2(c=0x0000000102934048, n=0x00000001024a1e10) + 248 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:913
    frame #37: 0x00000001017bb855 nimsuggest_dbg3 semStmt_vJZwz9bfROKrfrtM50y74CQ_3(c=0x0000000102934048, n=0x00000001024a1e10, flags=0) + 165 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1973
    frame #38: 0x0000000101889f62 nimsuggest_dbg3 semStmtAndGenerateGenerics_7YxUILpPxooC5qqa89a54dw_62(c=0x0000000102934048, n=0x00000001024a1e10) + 850 at /Users/timothee/git_clone/nim/Nim/compiler/sem.nim:568
    frame #39: 0x000000010188a431 nimsuggest_dbg3 myProcess_QAJdPOwMq9buTNGNGQO3ImA(context=0x0000000102934048, n=0x00000001024a1e10) + 417 at /Users/timothee/git_clone/nim/Nim/compiler/sem.nim:605
    frame #40: 0x00000001016e57f4 nimsuggest_dbg3 processTopLevelStmt_ZAiAbwXmDdFhEBV9b9avo9bNQ(graph=0x0000000101bbd048, n=0x00000001024a1e10, a=0x00007ffeee63cb10) + 660 at /Users/timothee/git_clone/nim/Nim/compiler/passes.nim:86
    frame #41: 0x00000001016e7639 nimsuggest_dbg3 processModule_zPTa50e0M05UK8aJ9bS48aw(graph=0x0000000101bbd048, module=0x0000000102734750, stream=0x0000000000000000) + 5849 at /Users/timothee/git_clone/nim/Nim/compiler/passes.nim:194
    frame #42: 0x00000001016833d8 nimsuggest_dbg3 compileModule_G7A63DimkOmtueyLoB89c8w(graph=0x0000000101bbd048, fileIdx=13, flags=4096) + 904 at /Users/timothee/git_clone/nim/Nim/compiler/modules.nim:83
    frame #43: 0x0000000101683a21 nimsuggest_dbg3 compileProject_KlDcF6rnOBDQLo439cvjPjg(graph=0x0000000101bbd048, projectFileIdx=13) + 545 at /Users/timothee/git_clone/nim/Nim/compiler/modules.nim:126
    frame #44: 0x00000001015eac27 nimsuggest_dbg3 execute_rHd9bI7FPTlXhsO4IVI2j7Q(cmd='\x01', file=0x00000001024a1fd0, dirtyfile=0x0000000000000000, line=5, col=3, graph=0x0000000101bbd048) + 2215 at /Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim:198
    frame #45: 0x00000001015ebd70 nimsuggest_dbg3 execCmd_KWRoUY2kSycfrYRYCp0oYA(cmd=0x000000010292ae08, graph=0x0000000101bbd048, cachedMsgs=0x0000000000000000) + 3728 at /Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim:440
    frame #46: 0x00000001015ec88c nimsuggest_dbg3 mainThread_goC9cK9b45Cq4fXrOTN5M2Yw_2(graph=0x0000000101bbd048) + 1484 at /Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim:474
    frame #47: 0x00000001015ed3d0 nimsuggest_dbg3 mainCommand_goC9cK9b45Cq4fXrOTN5M2Yw(graph=0x0000000101bbd048) + 2240 at /Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim:526
    frame #48: 0x00000001019a9bbc nimsuggest_dbg3 loadConfigsAndRunMainCommand_Zakie0oLAV2ve6DuAr547w(self=0x0000000101b9bd68, cache=0x0000000101b84030, conf=0x0000000101b9d048) + 3308 at /Users/timothee/git_clone/nim/Nim/compiler/cmdlinehelper.nim:91
    frame #49: 0x00000001015eda99 nimsuggest_dbg3 handleCmdLine_Yf8BWpRELzUoK9bMIFi74mw(cache=0x0000000101b84030, conf=0x0000000101b9d048) + 1417 at /Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim:614
    frame #50: 0x00000001015ee65d nimsuggest_dbg3 NimMainModule + 221 at /Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim:616
    frame #51: 0x00000001015ee579 nimsuggest_dbg3 NimMainInner + 9 at /Users/timothee/git_clone/nim/Nim/lib/system/threads.nim:598
    frame #52: 0x00000001015ee69a nimsuggest_dbg3 NimMain + 42 at /Users/timothee/git_clone/nim/Nim/lib/system/threads.nim:606
    frame #53: 0x00000001015ee6e7 nimsuggest_dbg3 main(argc=3, args=0x00007ffeee63d640, env=0x00007ffeee63d660) + 71 at /Users/timothee/git_clone/nim/Nim/lib/system/threads.nim:613
    frame #54: 0x00007fff6115b085 libdyld.dylib start + 1

@timotheecour
Copy link
Member Author

timotheecour commented Nov 3, 2018

/cc @Araq after a (painful... wish I had nim-lang/Nim#8276 ) reduction I get something without any imports:

proc fun(a: NimNode) =
  echo a.kind

macro mapLiterals(a: untyped): untyped =
  fun(a)

mapLiterals(0)

echo "sug bugs/nimsuggest/t01c.nim:9:3" | $nimc_D/bin/nimsuggest --stdin bugs/nimsuggest/t01c.nim

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
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

and a shorter stacktrace:

/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(616) nimsuggest
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(614) handleCmdLine
/Users/timothee/git_clone/nim/Nim/compiler/cmdlinehelper.nim(91) loadConfigsAndRunMainCommand
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(526) mainCommand
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(474) mainThread
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(440) execCmd
/Users/timothee/git_clone/nim/Nim/nimsuggest/nimsuggest.nim(198) execute
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(126) compileProject
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(78) compileModule
/Users/timothee/git_clone/nim/Nim/compiler/passes.nim(194) processModule
/Users/timothee/git_clone/nim/Nim/compiler/passes.nim(86) processTopLevelStmt
/Users/timothee/git_clone/nim/Nim/compiler/sem.nim(605) myProcess
/Users/timothee/git_clone/nim/Nim/compiler/sem.nim(568) semStmtAndGenerateGenerics
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1973) semStmt
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(913) semExprNoType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2534) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1914) semStmtList
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2422) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(895) semDirectOp
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(788) afterCallActions
/Users/timothee/git_clone/nim/Nim/compiler/sem.nim(463) semMacroExpr
/Users/timothee/git_clone/nim/Nim/compiler/vm.nim(1988) evalMacroCall
/Users/timothee/git_clone/nim/Nim/compiler/vm.nim(1034) rawExecute
/Users/timothee/git_clone/nim/Nim/compiler/vm.nim(396) compile
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(2175) genProc
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(263) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(1985) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(263) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(1944) gen
/Users/timothee/git_clone/nim/Nim/compiler/vmgen.nim(525) genCall
/Users/timothee/git_clone/nim/Nim/compiler/ast.nim(1421) skipTypes
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

@timotheecour timotheecour changed the title [major] SIGSEGV: Illegal storage access with include sequtils [major] SIGSEGV: Illegal storage access in skipTypes Nov 3, 2018
@timotheecour timotheecour changed the title [major] SIGSEGV: Illegal storage access in skipTypes [major] SIGSEGV: Illegal storage access in gen=>genCall=>skipTypes Nov 3, 2018
@nc-x
Copy link

nc-x commented Nov 3, 2018

nim check also fails on the snippet -

Error: internal error: (filename: "vmgen.nim", line: 1119, column: 19)
Traceback (most recent call last)
nim.nim(108)             nim
nim.nim(72)              handleCmdLine
cmdlinehelper.nim(91)    loadConfigsAndRunMainCommand
main.nim(254)            mainCommand
main.nim(58)             commandCheck
modules.nim(126)         compileProject
modules.nim(71)          compileModule
passes.nim(194)          processModule
passes.nim(86)           processTopLevelStmt
sem.nim(605)             myProcess
sem.nim(568)             semStmtAndGenerateGenerics
semstmts.nim(1973)       semStmt
semexprs.nim(913)        semExprNoType
semexprs.nim(2534)       semExpr
semstmts.nim(1914)       semStmtList
semexprs.nim(2422)       semExpr
semexprs.nim(895)        semDirectOp
semexprs.nim(788)        afterCallActions
sem.nim(463)             semMacroExpr
vm.nim(1988)             evalMacroCall
vm.nim(1034)             rawExecute
vm.nim(396)              compile
vmgen.nim(2175)          genProc
vmgen.nim(263)           gen
vmgen.nim(1930)          gen
msgs.nim(542)            genMagic
msgs.nim(535)            internalError
msgs.nim(411)            rawMessage
msgs.nim(408)            rawMessage
msgs.nim(324)            handleError
msgs.nim(314)            quit

@timotheecour
Copy link
Member Author

timotheecour commented Nov 3, 2018

indeed... but when I simplify a bit further, nim check still gives internal error (see nim-lang/Nim#9609) but

echo "sug bugs/nimsuggest/t01d.nim:3:6" | $nimc_D/bin/nimsuggest --stdin bugs/nimsuggest/t01d.nim
doesn't give internal error anymore:

macro mapLiterals(a: untyped): untyped =
  echo a.kind
mapLiterals(0)

instead it (strangely, is that a bug?) gives all the symbols; EDIT: I'm reporting this particular bug here: #99

@timotheecour
Copy link
Member Author

timotheecour commented Nov 15, 2018

@nc-x

nim check also fails on the snippet -

so nim check wasn't related to this issue : now that nim-lang/Nim#9609 was fixed, nim check bugs/nimsuggest/t01c.nim doesn't crash anymore (just gives normal errors), but the bugs are still there for nimsuggest

@narimiran
Copy link
Member

I couldn't reproduce the sigsegv with v0.19.9, neither with nimusggest nor with nim check.

@nc-x
Copy link

nc-x commented Mar 29, 2019

@narimiran
Sequtils changed between then and now. Use this old sequtils with current nimsuggest. It crashes. So the crash is related to some code in sequtils.

@Araq Araq reopened this Mar 29, 2019
@saem
Copy link

saem commented Jan 10, 2021

Even with the old sequtils, I can no longer reproduce this with the latest nimsuggest.

$ nimsuggest --version
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-01-10
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: dbff2cd938b326279de0f3f97b2dd8c54a90468a
active boot switches: -d:release --gc:markAndSweep

I don't think it's worth keeping this open unless someone can reproduce it.

@timotheecour
Copy link
Member Author

I can no longer reproduce this

@saem if possible, you could add reduced case #93 (comment) as a regression test case

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

No branches or pull requests

5 participants