test: keep cif structs alive during gc by addaleax · Pull Request #380 · node-ffi/node-ffi

@addaleax

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 mentioned this pull request

Apr 13, 2017

4 tasks

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