Skip to content

Conversation

addaleax
Copy link
Contributor

Up until now, test/callback.js assumed that the cb.cif object
would not be garbage collected and was available to Callback::Invoke.

That has never been a valid assumption, but as of
nodejs/node#12141 Buffers created with
new Buffer(n) each have their own ArrayBuffer which gets
garbage-collected much more easily, which in turn would
crash the test suite here.

To (lazy-)fix this, assign cb._cif to some global variable that is
guaranteed to stay alive.

Up until now, test/callback.js assumed that the `cb.cif` object
would not be garbage collected and was available to `Callback::Invoke`.

That has never been a valid assumption, but as of
nodejs/node#12141 Buffers created with
`new Buffer(n)` each have their own `ArrayBuffer` which gets
garbage-collected much more easily, which in turn would
crash the test suite here.

To (lazy-)fix this, assign `cb._cif` to some global variable that is
guaranteed to stay alive.
@addaleax
Copy link
Contributor Author

Ping @TooTallNate ? It would be cool to see this merged, or addressed in some other way, otherwise I fear that this module might need to be removed from CITGM coverage…

@TooTallNate
Copy link
Member

I'm sorry for not getting to this sooner. I'm not a fan of this (lazy-)fix, so this fell off of my radar. Really this should be fixed in lib/callback.js or something like that. It's possibly fixed by #391.

addaleax added a commit to node-ffi-napi/node-ffi that referenced this pull request Nov 27, 2017
Up until now, test/callback.js assumed that the `cb.cif` object
would not be garbage collected and was available to `Callback::Invoke`.

That has never been a valid assumption, but as of
nodejs/node#12141 Buffers created with
`new Buffer(n)` each have their own `ArrayBuffer` which gets
garbage-collected much more easily, which in turn would
crash the test suite here.

To (lazy-)fix this, assign `cb._cif` to some global variable that is
guaranteed to stay alive.

PR-URL: node-ffi#380
@addaleax addaleax closed this Nov 27, 2017
@addaleax addaleax deleted the cif-gb-fix branch November 27, 2017 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants