Commit f348140
committed
fix(native): remove AdjustExternalMemory from destructors to fix Node 24 crash
Node.js 24's V8 has stricter validation in ArrayBufferSweeper::~ArrayBufferSweeper()
during Heap::TearDown(). Calling AdjustExternalMemory() from ObjectWrap destructors
races with the sweeper's teardown, causing the assertion:
Check failed: static_cast<int64_t>(amount_before) >= -delta.
This manifested as crashes on Node 24.x only, with all tests passing but the
process crashing during shutdown.
The fix removes AdjustExternalMemory() calls from VideoFrame and AudioData
destructors. External memory tracking is now handled exclusively in Close(),
which the WebCodecs spec mandates users must call for proper resource management.
If users violate the spec and don't call Close(), external memory accounting
will be slightly off, but the process won't crash. This is acceptable since
spec-violating code is a user error.
Ref: nodejs/node-addon-api#1153
Ref: nodejs/node#384921 parent 8b7044d commit f348140
2 files changed
+25
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
215 | 222 | | |
216 | 223 | | |
217 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
434 | 440 | | |
435 | 441 | | |
436 | 442 | | |
| |||
0 commit comments