Haven't checked with a debugger, but I would assume it's a memory issue. I'm not sure if you're supposed to be able to pass managed memory in and out off dynamic libraries. It at least used to be the case that you had to link against nimrtl in order for it to only run one instance of the GC. But I think this got relaxed somewhat with ARC/ORC (I seem to remember that it's only required for ORC nowadays, but maybe someone else knows for sure).
That's where I'd start looking anyways