I have a native extension compiled as a dynamic library and loaded by the main 
program.

In the native extension there is below code that causes SEGV while Nim is 
running GC for data allocated. The same code would run fine if put in the main 
program.
    
    
    discard VM.eval("(ns N)")
    
    
    Run
    
    
    Traceback (most recent call last)
    /Users/gcao/proj/gene/src/genex/http.nim(176) init
    /Users/gcao/proj/gene/src/gene/interpreter_base.nim(167) eval
    /Users/gcao/.choosenim/toolchains/nim-1.4.8/lib/system.nim(937) eval
    /Users/gcao/.choosenim/toolchains/nim-1.4.8/lib/system/arc.nim(169) 
nimDestroyAndDispose
    /Users/gcao/.choosenim/toolchains/nim-1.4.8/lib/system/orc.nim(413) 
nimDecRefIsLastCyclicDyn
    /Users/gcao/.choosenim/toolchains/nim-1.4.8/lib/system/orc.nim(394) 
rememberCycle
    /Users/gcao/.choosenim/toolchains/nim-1.4.8/lib/system/orc.nim(128) 
unregisterCycle
    SIGSEGV: Illegal storage access. (Attempt to read from nil?)
    
    
    Run

I'm trying to debug this issue. Based on the stack trace, there might be cyclic 
references. My data type does allow cyclic references. However in the code 
above, it probably will not create a real cyclic reference.

The first thing I want to figure out is which data/variable is being recycled. 
I've enabled debugger but don't get much information out of the debugger other 
than a stack with a lot of "optimized out".

I tried to pass a C flag "-O0" but it is ignored because the command has "-g3 
-Og".

How should I approach fixing this issue?

Any help is much appreciated!

Reply via email to