Skip to content

Commit

Permalink
test: keep cif structs alive during gc
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
addaleax committed Apr 13, 2017
1 parent 8fc355f commit 334067e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('Callback', function () {
// should be ok
bindings.call_cb()

global.cif = cb._cif
cb = null // KILL!!
gc()

Expand Down Expand Up @@ -276,6 +277,7 @@ describe('Callback', function () {
})
})

global.cif = cb._cif
cb = null // KILL!!
gc()

Expand Down

0 comments on commit 334067e

Please sign in to comment.