Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Access violation with GC and C module

Moderators: kris

Posted: 10/28/08 13:36:52 Modified: 10/28/08 14:31:20

EDIT: Problem has been resolved, see post below.

I am not sure whether this is a Tango issue, but since it seems the Tango GC is a modified version of the Phobos one it may apply.

I am linking a Tango program with a C library, namely, Lua 5.1.3 which I compiled using dmc on Windows. As a binding, I use LuaLib? from the bindings project on dsource. I use DMD 1.033.

The main loop of the D program calls a couple of Lua callbacks in script files every frame. This works fine at first, but after a while (it only happens when I do certain things, but is perfectly reproducible) I always get an access violation like this:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at _luaS_newlstr (0x004511d5) thread(1292)

To be clear, this exception occurs in the C library, and the code path leading up to it should be called every frame, but only after 30-60 seconds does this exception occur.

Now, if I call GC.disable() in my main function, I get no such problems.

Is there something I have to do to make the GC 'play nice' with external C modules? Or is this possibly a GC bug?

Author Message

Posted: 10/28/08 14:30:19

Apologies for the false alarm. After some more debugging, it turns out the cause of this is a bug in a finalizer in the LuaLib? binding. I will report the bug there.