Skip to content

Crash with node-ffi 2.0 #238

@rosen-vladimirov

Description

@rosen-vladimirov

Hi,

I have two different problems (one on MAC and one on Windows), but as I believe both have the same root cause, I'll add them here. I can separate them in case you think they are not connected:

Using node-ffi 2.0 on MAC

I'm trying a very simple script, that leads to core dump on Mac OS:

var ffi = require("ffi");
global.gc();
console.log("END");

When I call it with:

iojs --expose_gc --nouse_idle_notification --trace_gc test.js

I receive core dump.

I've set DEBUG environment variable and you can find the output in this gist I've also placed there the core dump file in case it can help.
I'm using iojs 3.3.0 and latest versions of ffi and ref:

 iojs
> process.versions
{ http_parser: '2.5.0',
  node: '3.3.0',
  v8: '4.4.63.30',
  uv: '1.7.3',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  modules: '45',
  openssl: '1.0.2d' }

Please note the crash is on the line global.gc().

Using node-ffi on Windows

On Windows the issues is more complicated, but it is also related to garbage collection. In our code we are trying to call methods from CoreFoundation.dll, which is part of iTunes installation. When we have some short calls and our process terminates, everything is working fine. But when our process starts working for some long time, we receive Assertion error:

Assertion failed: (obj_data) != (nullptr), file src\node_buffer.cc,  line 150

It looks like the garbage collector had collected something that we are trying to use later.
So we've tried to simplify the reproduction case and we've found that we fail only when trying to create ForeignFunction for specific method of the dll. Please note - we are not using them in the test script, just using ffi.

You can find the repro script and the output when DEBUG=* in this gist

I believe the problem is not in the dll itself, as the same code is working fine with node 0.10, node 0.12, iojs 2.x

Could you take a look at these issues? I believe the problem is in iojs's garbage collection, but I'm not able to reproduce the issue on Windows with all calls, only some of them lead to crash when garbage collection is working.

Your help is really appreciated. I'm looking forward to hearing from you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions