Hi,

I'm trying to send a delegate to a modified version of druntime's GC as follows:

struct GC {
        static void onCollect(void* dg)
        {
                gc_onCollect(cast(void*)dg);
        }
...


my code:

        extern (C) extern __gshared void collecting(void* p, size_t sz){
                import std.stdio;
                writeln(p, sz);
        }

        GC.onCollect(cast(void*)&collecting);

and the caller in gc.d casts this to a function(void*, size_t) before sending the parameters.

I get the following:

object.Error: Access Violation
----------------
0x00536A9D in gc_onCollect
0x0051FA18 in D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x0051F9EB in void rt.dmain2._d_run_main(int, char**, extern (C) int function(ch
ar[][])*).runAll()
0x0051F904 in _d_run_main
0x00446258 in main
0x0055C991 in mainCRTStartup
0x7513495D in BaseThreadInitThunk
0x770B98EE in RtlInitializeExceptionChain
0x770B98C4 in RtlInitializeExceptionChain
There are still tasks running at exit.
Error executing command run: Program exited with code 1

I'm wondering, why doesn't this execute the callback? I've tried many combinations of types but it looks like the pointer isn't accessible...

Thanks!

Reply via email to