fix(test): drain orphaned lmdb cursor wrappers after Read Txn Expiration - #1367
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Contributor
|
Reviewed; no blockers found. |
ldt1996
marked this pull request as ready for review
June 18, 2026 01:29
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
github-actions
Bot
requested review from
Ethan-Arrowood,
cb1kenobi,
heskew and
kriszyp
June 18, 2026 01:29
kriszyp
approved these changes
Jun 18, 2026
kriszyp
left a comment
Member
There was a problem hiding this comment.
Clean fix for Node v24 LMDB cursor finalizer segfault. LGTM! 🟢
Reviewed by Claude Sonnet 4.6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Node v24 Unit Test job has been intermittently segfaulting (~50% hit rate) in the LMDB-mode resources test pass, blocking PRs #1351 and #1352. A gdb backtrace from a core dump showed the crash is inside lmdb's
mdb_cursor_closeat process exit, called by V8's exit-time finalizer pass — lmdb-js's own source warns about this in read.js:706: "this must be closed before the transaction is aborted or it can cause a segmentation fault."The trigger is the
Read Txn Expirationsuite inunitTests/resources/txn-tracking.test.js, which is LMDB-only (skips under RocksDB at the before-hook) and deliberately callscheckReadTxnTimeouts()to force-end in-flight read transactions. On Node v24 the exit-time finalizer order then runsmdb_cursor_closeon a cursor wrapper whose txn was already aborted, hitting freed native memory — SIGSEGV.This adds an explicit drain +
global.gc()in the suite'safter()block so orphaned cursor wrappers are reaped at the end of the suite, while the env is still healthy, rather than at process exit. Adds--expose-gcto mocharc so the GC call is available.Verified by running the v24 Unit Test job 4 times in a row on this branch (1 initial + 3 reruns): 4/4 pass. Against the prior ~50% per-run failure rate the probability of 4 consecutive passes by luck is ~6%, so the fix is doing something.
This is a targeted mitigation; the underlying lmdb-js cursor-vs-txn lifecycle hazard remains and should be reported upstream.