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

Compiler segfaults on simple importcpp in js mode [regression] #4632

Closed
mcclure opened this issue Aug 20, 2016 · 1 comment
Closed

Compiler segfaults on simple importcpp in js mode [regression] #4632

mcclure opened this issue Aug 20, 2016 · 1 comment

Comments

@mcclure
Copy link

mcclure commented Aug 20, 2016

I am using self-built nim from git. I tested the following with 0062077 . The problem appeared only after I upgraded from 07d7d35 (I did not see the problem with 07d7d35 and the same code).

I write this code:

type QCbase* {.importc.} = ref object of RootObj
    num1* {.importc.}: float
    str2* {.importc.}: cstring
proc newQCbase*() : QCbase {.importcpp:"new QCbase".}

let inst1 : QCbase  = newQCbase()

And compile it with nim js -o:testNim2.js testNim2.nim, I get an error:

Hint: used config file 'C:\msys64\home\Andi\work\g\Nim\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: testnim2 [Processing]
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

I do NOT get the error if I instead use the code:

type QCbase* {.importc.} = ref object of RootObj
    num1* {.importc.}: float
    str2* {.importc.}: cstring
proc newQCbase*() : QCbase {.importcpp:"new QCbase(@)".}

let inst1 : QCbase  = newQCbase()

With the difference being the (@).

I also do not get a segfault if I compile with nim c instead of nim js.

This might be related to the fix for #4496

@mcclure
Copy link
Author

mcclure commented Aug 20, 2016

Under certain circumstances I find that on repeated invocations, instead of a segfault I get

command line(0, 1) Error: internal error: gen: unknown node type: nkNone
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp js <file>

I can give you the reproduction steps for this if it is helpful, but I assume this is just a byproduct of the compiler segfault.

@Araq Araq closed this as completed in 200ccff Aug 23, 2016
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

2 participants