I need to pass around some data between Nim and C, and this 
`someCAllocFunction` returns a void pointer. I tried casting it to a `ptr 
MyType` and setting its value using `point[] = MyType()` (in reality I'm using 
an object with some fields, and the object is initialized in a separate 
function). But then, in a callback I passed to C, I'm trying to access my data 
again, but a `SIGSEGV` is raised. 
    
    
    instance of TestAutowrenType
    Traceback (most recent call last)
    autowren.nim(143)        autowren
    autowren.nim(136)        w_data=
    autowren.nim(130)        data=
    gc.nim(289)              unsureAsgnRef
    gc.nim(185)              decRef
    SIGSEGV: Illegal storage access. (Attempt to read from nil?)
    
    
    Run

Here's the source code of my program: 
[https://github.com/liquid600pgm/rapid/blob/master/src/scripting/autowren.nim](https://github.com/liquid600pgm/rapid/blob/master/src/scripting/autowren.nim)

I understood this as the GC removing my object while it's passed around in C 
code, and that's why I wanted to mark it as referenced.

Reply via email to