yglukhov / nimx

GUI library
MIT License
1.09k stars 75 forks source link

regression: test demo fails: `SIGSEGV: Illegal storage access` #341

Closed timotheecour closed 5 years ago

timotheecour commented 5 years ago

cd nimx cd test nake SIGSEGV: Illegal storage access

upon further inspection: nake produces (and runs) ./nakefile; and running ./nakefile compiles a nim binary (IIUC) and runs this binary then produces that SIGSEGV: Illegal storage access

however I have no way to know which is that binary (so I can't debug that program via lldb ; see https://github.com/fowlmouth/nake/issues/64 ; also, I can't debug via lldb ./nakefile either, this time because of https://github.com/nim-lang/Nim/issues/9634)

Note: after echo-style debugging it crashes here: inside result = superTypeAux(getImpl(t[1].symbol))


proc superTypeAux(t: NimNode, indent: int): NimNode =
    doAssert(indent < 10, "Recursion too deep")

    template superTypeAux(t: NimNode): NimNode = superTypeAux(t, indent + 1)
    proc log(args: varargs[string, `$`]) =
        discard
        # echo "- ", "  " * indent, args.join(" ")

    log "superTypeAux: ", treeRepr(t)
    case t.kind
    of nnkSym:
        if $t == "RootRef": return t
        let ty = getTypeImpl(t)
        log "TypeKind: ", ty.typeKind
        result = superTypeAux(ty)
    of nnkBracketExpr:
        echo "ok1"
        echo t.len
        echo t[1] == nil
        result = superTypeAux(getImpl(t[1].symbol))
        echo "ok2"

EDIT maybe even crashes here: getTypeImpl(t[^1]) in result = superTypeAux(getTypeImpl(t[^1])) in the nnkRefTy clause

timotheecour commented 5 years ago

/cc @yglukhov looks like it was same root cause with https://github.com/nim-lang/Nim/issues/9600 because after rebuilding after the commit that fixed it (https://github.com/nim-lang/Nim/commit/fc740c54ec7af592ff3486c8cc296bb4f65eb340) this now works; thanks @jcosborn !