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

nim check gives SIGSEGV: Illegal storage access ; maybe because of sizeof #9610

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

Comments

@timotheecour
Copy link
Member

timotheecour commented Nov 3, 2018

nim check Nim/lib/system/gc.nim gives SIGSEGV: Illegal storage access

Traceback (most recent call last)
/Users/timothee/git_clone/nim/Nim/compiler/nim.nim(108) nim
/Users/timothee/git_clone/nim/Nim/compiler/nim.nim(72) handleCmdLine
/Users/timothee/git_clone/nim/Nim/compiler/cmdlinehelper.nim(91) loadConfigsAndRunMainCommand
/Users/timothee/git_clone/nim/Nim/compiler/main.nim(254) mainCommand
/Users/timothee/git_clone/nim/Nim/compiler/main.nim(58) commandCheck
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(126) compileProject
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(71) compileModule
/Users/timothee/git_clone/nim/Nim/compiler/passes.nim(200) 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(1967) semStmt
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(913) semExprNoType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2549) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1758) semProc
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1686) semProcAux
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(1600) semProcBody
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2531) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1908) semStmtList
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2529) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(1553) semAsgn
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(59) semExprWithType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2508) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(277) semCast
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(59) semExprWithType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2439) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2052) semMagic
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(894) semDirectOp
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(744) semOverloadedCallAnalyseEffects
/Users/timothee/git_clone/nim/Nim/compiler/semcall.nim(498) semOverloadedCall
/Users/timothee/git_clone/nim/Nim/compiler/semcall.nim(307) resolveOverloads
/Users/timothee/git_clone/nim/Nim/compiler/semcall.nim(93) pickBestCandidate
/Users/timothee/git_clone/nim/Nim/compiler/sigmatch.nim(2427) matches
/Users/timothee/git_clone/nim/Nim/compiler/sigmatch.nim(2367) matchesAux
/Users/timothee/git_clone/nim/Nim/compiler/sigmatch.nim(2185) prepareOperand
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(41) semOperand
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2430) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(234) semConv
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(59) semExprWithType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2439) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2052) semMagic
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(895) semDirectOp
/Users/timothee/.choosenim/toolchains/nim-0.19.0/lib/system.nim(414) afterCallActions
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

among other things, this causes NimLime to crash (and forces one to restart sublimetext)

@timotheecour
Copy link
Member Author

likewise with Nim/lib/pure/ioselects/ioselectors_select.nim

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000100196a77 nim_temp afterCallActions_Qn3T9bt6Cg4I7XaYRMg219aw(c=0x0000000100b645b0, n=0x0000000107bbc828, orig=0x0000000107bc1048, flags=4480) + 839 at /Users/timothee/git_clone/nim/Nim/lib/system.nim:469
   466
   467  template `!=`*(x, y: untyped): untyped =
   468    ## unequals operator. This is a shorthand for ``not (x == y)``.
-> 469    not (x == y)
   470
   471  template `>=`*(x, y: untyped): untyped =
   472    ## "is greater or equals" operator. This is the same as ``y <= x``.
Target 0: (nim_temp) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000100196a77 nim_temp afterCallActions_Qn3T9bt6Cg4I7XaYRMg219aw(c=0x0000000100b645b0, n=0x0000000107bbc828, orig=0x0000000107bc1048, flags=4480) + 839 at /Users/timothee/git_clone/nim/Nim/lib/system.nim:469
    frame #1: 0x000000010018c473 nim_temp semDirectOp_vJZwz9bfROKrfrtM50y74CQ_5(c=0x0000000100b645b0, n=0x0000000107bc6e10, flags=4480) + 243 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:895
    frame #2: 0x00000001001db32f nim_temp semMagic_NYxU2DkHA0Gt5fsL9bYZdog_2(c=0x0000000100b645b0, n=0x0000000107bc6e10, s=0x0000000104bcd4c8, flags=4480) + 5823 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2055
    frame #3: 0x000000010013eb3f nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc6e10, flags=4480) + 5375 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2442
    frame #4: 0x000000010020eac7 nim_temp semOperand_vJZwz9bfROKrfrtM50y74CQ_35(c=0x0000000100b645b0, n=0x0000000107bc6e10, flags=384) + 119 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:41
    frame #5: 0x00000001002aa007 nim_temp prepareOperand_2XvpHGePOMU89c3szM9bT9bMg(c=0x0000000100b645b0, formal=0x0000000104bbbca8, a=0x0000000107bc6e10) + 375 at /Users/timothee/git_clone/nim/Nim/compiler/sigmatch.nim:2185
    frame #6: 0x00000001002af01c nim_temp matchesAux_jWX5qJnM9cS16h0kw9aDyhrg(c=0x0000000100b645b0, n=0x0000000107bc6da0, nOrig=0x0000000107ba9d68, m=0x00007ffeefbf7c10, marker=0x00007ffeefbf7998) + 19900 at /Users/timothee/git_clone/nim/Nim/compiler/sigmatch.nim:2367
    frame #7: 0x00000001002b4094 nim_temp matches_BxEsf1Gt7Hq3usrwPERzyA_2(c=0x0000000100b645b0, n=0x0000000107bc6da0, nOrig=0x0000000107ba9d68, m=0x00007ffeefbf7c10) + 372 at /Users/timothee/git_clone/nim/Nim/compiler/sigmatch.nim:2427
    frame #8: 0x000000010019fd88 nim_temp pickBestCandidate_IETBO4nA4t9bpyaJXqQ9aSTg(c=0x0000000100b645b0, headSymbol=0x0000000107bc6d68, n=0x0000000107bc6da0, orig=0x0000000107ba9d68, initialBinding=0x0000000000000000, filter=487424, best=0x00007ffeefbf84d8, alt=0x00007ffeefbf81c0, errors=0x00007ffeefbf8578, diagnosticsFlag='\0', errorsEnabled='\0') + 1528 at /Users/timothee/git_clone/nim/Nim/compiler/semcall.nim:93
    frame #9: 0x00000001001a1483 nim_temp resolveOverloads_deoiEhU508ju9btmg2AXeFw(c=0x0000000100b645b0, n=0x0000000107bc6da0, orig=0x0000000107ba9d68, filter=487424, flags=2048, errors=0x00007ffeefbf8578, errorsEnabled='\0', Result=0x00007ffeefbf84d8) + 1027 at /Users/timothee/git_clone/nim/Nim/compiler/semcall.nim:307
    frame #10: 0x000000010015a072 nim_temp semOverloadedCall_pBkKnME6t9c8v6khuDD76Fg(c=0x0000000100b645b0, n=0x0000000107bc6da0, nOrig=0x0000000107ba9d68, filter=487424, flags=2048) + 258 at /Users/timothee/git_clone/nim/Nim/compiler/semcall.nim:498
    frame #11: 0x0000000100196cfb nim_temp semOverloadedCallAnalyseEffects_9b1JieByYAFP9bIuFhYqD8AA(c=0x0000000100b645b0, n=0x0000000107bc6da0, nOrig=0x0000000107ba9d68, flags=2048) + 251 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:744
    frame #12: 0x000000010018c412 nim_temp semDirectOp_vJZwz9bfROKrfrtM50y74CQ_5(c=0x0000000100b645b0, n=0x0000000107bc6da0, flags=2048) + 146 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:894
    frame #13: 0x000000010013eb0c nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc6da0, flags=2048) + 5324 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2441
    frame #14: 0x0000000100141744 nim_temp semExprWithType_vJZwz9bfROKrfrtM50y74CQ(c=0x0000000100b645b0, n=0x0000000107bc6da0, flags=0) + 116 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:59
    frame #15: 0x00000001001e60fb nim_temp semCast_7YxUILpPxooC5qqa89a54dw_36(c=0x0000000100b645b0, n=0x0000000107bc6cf8) + 555 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:277
    frame #16: 0x000000010013fcd2 nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc6cf8, flags=3072) + 9874 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2511
    frame #17: 0x0000000100141744 nim_temp semExprWithType_vJZwz9bfROKrfrtM50y74CQ(c=0x0000000100b645b0, n=0x0000000107bc6cf8, flags=1024) + 116 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:59
    frame #18: 0x0000000100187ec3 nim_temp semAsgn_mkzYzG9avRzHz5NmIFyZdRg(c=0x0000000100b645b0, n=0x0000000107bc6cc0, mode='\0') + 4147 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:1559
    frame #19: 0x000000010013ff8b nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc6cc0, flags=0) + 10571 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2532
    frame #20: 0x00000001001e9905 nim_temp semStmtList_vJZwz9bfROKrfrtM50y74CQ_28(c=0x0000000100b645b0, n=0x0000000107bc64e0, flags=0) + 661 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1914
    frame #21: 0x000000010013ffe3 nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc64e0, flags=0) + 10659 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2534
    frame #22: 0x000000010019ec15 nim_temp semProcBody_7YxUILpPxooC5qqa89a54dw_4(c=0x0000000100b645b0, n=0x0000000107bc64e0) + 149 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:1600
    frame #23: 0x000000010019ddaa nim_temp semProcAux_HtuGXsziiAueY6wARBVVAA(c=0x0000000100b645b0, n=0x0000000107bc6390, kind='\f', validPragmas="", phase='\0') + 13482 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1692
    frame #24: 0x000000010020b3a7 nim_temp semProc_7YxUILpPxooC5qqa89a54dw_52(c=0x0000000100b645b0, n=0x0000000107bc6390) + 119 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1764
    frame #25: 0x00000001001402e9 nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc6390, flags=0) + 11433 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2552
    frame #26: 0x00000001001e9905 nim_temp semStmtList_vJZwz9bfROKrfrtM50y74CQ_28(c=0x0000000100b645b0, n=0x0000000107bc6358, flags=0) + 661 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1914
    frame #27: 0x000000010013ffe3 nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc6358, flags=0) + 10659 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2534
    frame #28: 0x00000001001a9434 nim_temp semWhen_5C4HPXQuhxlMYIzPbe36lg(c=0x0000000100b645b0, n=0x0000000107bc87f0, semCheck='\x01') + 4532 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2104
    frame #29: 0x000000010013f0d1 nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bc87f0, flags=64) + 6801 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2458
    frame #30: 0x00000001001e9905 nim_temp semStmtList_vJZwz9bfROKrfrtM50y74CQ_28(c=0x0000000100b645b0, n=0x0000000107bcf8d0, flags=64) + 661 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1914
    frame #31: 0x000000010013ffe3 nim_temp semExpr_vJZwz9bfROKrfrtM50y74CQ_2(c=0x0000000100b645b0, n=0x0000000107bcf8d0, flags=64) + 10659 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:2534
    frame #32: 0x000000010013d5c8 nim_temp semExprNoType_7YxUILpPxooC5qqa89a54dw_2(c=0x0000000100b645b0, n=0x0000000107bcf8d0) + 248 at /Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim:913
    frame #33: 0x0000000100141455 nim_temp semStmt_vJZwz9bfROKrfrtM50y74CQ_3(c=0x0000000100b645b0, n=0x0000000107bcf8d0, flags=0) + 165 at /Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim:1973
    frame #34: 0x0000000100211d82 nim_temp semStmtAndGenerateGenerics_7YxUILpPxooC5qqa89a54dw_62(c=0x0000000100b645b0, n=0x0000000107bcf8d0) + 850 at /Users/timothee/git_clone/nim/Nim/compiler/sem.nim:568
    frame #35: 0x0000000100212261 nim_temp myProcess_QAJdPOwMq9buTNGNGQO3ImA(context=0x0000000100b645b0, n=0x0000000107bcf8d0) + 417 at /Users/timothee/git_clone/nim/Nim/compiler/sem.nim:605
    frame #36: 0x0000000100270e04 nim_temp processTopLevelStmt_ZAiAbwXmDdFhEBV9b9avo9bNQ(graph=0x0000000100b5d6d8, n=0x0000000107bcf8d0, a=0x00007ffeefbfbc00) + 660 at /Users/timothee/git_clone/nim/Nim/compiler/passes.nim:86
    frame #37: 0x0000000100272c59 nim_temp processModule_zPTa50e0M05UK8aJ9bS48aw(graph=0x0000000100b5d6d8, module=0x0000000105504288, stream=0x0000000000000000) + 5849 at /Users/timothee/git_clone/nim/Nim/compiler/passes.nim:194
    frame #38: 0x0000000100551918 nim_temp compileModule_G7A63DimkOmtueyLoB89c8w(graph=0x0000000100b5d6d8, fileIdx=11, flags=4096) + 520 at /Users/timothee/git_clone/nim/Nim/compiler/modules.nim:76
    frame #39: 0x0000000100552393 nim_temp compileProject_KlDcF6rnOBDQLo439cvjPjg(graph=0x0000000100b5d6d8, projectFileIdx=-1) + 563 at /Users/timothee/git_clone/nim/Nim/compiler/modules.nim:126
    frame #40: 0x00000001000e293f nim_temp commandCheck_ikP0vuP6oxqlYdG7q9cY7sA_5(graph=0x0000000100b5d6d8) + 223 at /Users/timothee/git_clone/nim/Nim/compiler/main.nim:58
    frame #41: 0x00000001000e542a nim_temp mainCommand_ikP0vuP6oxqlYdG7q9cY7sA(graph=0x0000000100b5d6d8) + 8314 at /Users/timothee/git_clone/nim/Nim/compiler/main.nim:254
    frame #42: 0x000000010055aaac nim_temp loadConfigsAndRunMainCommand_Zakie0oLAV2ve6DuAr547w(self=0x0000000100b2bd68, cache=0x0000000100b16030, conf=0x0000000100b0f048) + 3404 at /Users/timothee/git_clone/nim/Nim/compiler/cmdlinehelper.nim:91
    frame #43: 0x00000001000219e7 nim_temp handleCmdLine_I9aitIr13Z1B6wHv5vzMf2w(cache=0x0000000100b16030, conf=0x0000000100b0f048) + 535 at /Users/timothee/git_clone/nim/Nim/compiler/nim.nim:72
    frame #44: 0x0000000100022960 nim_temp NimMainModule + 192 at /Users/timothee/git_clone/nim/Nim/compiler/nim.nim:108
    frame #45: 0x0000000100022899 nim_temp NimMainInner + 9 at /Users/timothee/git_clone/nim/Nim/lib/system.nim:3388
    frame #46: 0x00000001000229da nim_temp NimMain + 42 at /Users/timothee/git_clone/nim/Nim/lib/system.nim:3396
    frame #47: 0x0000000100022a27 nim_temp main(argc=3, args=0x00007ffeefbfc540, env=0x00007ffeefbfc560) + 71 at /Users/timothee/git_clone/nim/Nim/lib/system.nim:3403
    frame #48: 0x00007fff6115b085 libdyld.dylib start + 1

@timotheecour
Copy link
Member Author

timotheecour commented Nov 3, 2018

/cc @krux02 it looks related to sizeof:
nim check shows Error: cannot evaluate 'sizeof' because its type is not defined completely right before SIGSEGV: Illegal storage access

minimized to remove all dependencies:

const platformHeaders = """#include <sys/select.h>
                             #include <sys/time.h>
                             #include <sys/types.h>
                             #include <unistd.h>"""
type
  Fdset {.importc: "fd_set", header: platformHeaders, pure, final.} = object

when hasThreadSupport:
  type
    SelectorImpl[T] = object
else:
  type
    SelectorImpl[T] = object

type
  SelectEventImpl = object
    rsock: distinct int

proc newSelectEvent*() =
  let temp0=sizeof(SelectEventImpl)
Traceback (most recent call last)
/Users/timothee/git_clone/nim/Nim/compiler/nim.nim(108) nim
/Users/timothee/git_clone/nim/Nim/compiler/nim.nim(72) handleCmdLine
/Users/timothee/git_clone/nim/Nim/compiler/cmdlinehelper.nim(91) loadConfigsAndRunMainCommand
/Users/timothee/git_clone/nim/Nim/compiler/main.nim(254) mainCommand
/Users/timothee/git_clone/nim/Nim/compiler/main.nim(58) commandCheck
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(126) compileProject
/Users/timothee/git_clone/nim/Nim/compiler/modules.nim(71) compileModule
/Users/timothee/git_clone/nim/Nim/compiler/passes.nim(197) 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(1977) semStmt
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(913) semExprNoType
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2552) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1764) semProc
/Users/timothee/git_clone/nim/Nim/compiler/semstmts.nim(1692) semProcAux
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(1600) semProcBody
/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(2442) semExpr
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(2055) semMagic
/Users/timothee/git_clone/nim/Nim/compiler/semexprs.nim(895) semDirectOp
/Users/timothee/git_clone/nim/Nim/lib/system.nim(469) afterCallActions
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

[EDIT] indeed, seems like a regression, 0.19.0 didn't give SIGSEGV

@timotheecour timotheecour changed the title nim check Nim/lib/system/gc.nim gives SIGSEGV: Illegal storage access nim check gives SIGSEGV: Illegal storage access ; maybe because of sizeof Nov 3, 2018
@Araq Araq closed this as completed in a2e6a87 Nov 3, 2018
@timotheecour
Copy link
Member Author

@Araq thanks!

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

No branches or pull requests

1 participant