Skip to content

Commit 334067e

Browse files
committed
test: keep cif structs alive during gc
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.
1 parent 8fc355f commit 334067e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/callback.js

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ describe('Callback', function () {
8080
// should be ok
8181
bindings.call_cb()
8282

83+
global.cif = cb._cif
8384
cb = null // KILL!!
8485
gc()
8586

@@ -276,6 +277,7 @@ describe('Callback', function () {
276277
})
277278
})
278279

280+
global.cif = cb._cif
279281
cb = null // KILL!!
280282
gc()
281283

0 commit comments

Comments
 (0)