Repository navigation
Fix crash when reloading the addon in worker threads - #119
Open
CheckPickerUpper wants to merge 2 commits into
Open
CheckPickerUpper wants to merge 2 commits into
CheckPickerUpper wants to merge 2 commits into
Conversation
worker-test.js removed worker-test.log at the top level, so the worker thread removed it too when it started. If the worker took longer than the main thread's 100 ms lock hold to start, it deleted the "releasing main lock" line the main thread had already written, and the assertion failed with only "worker lock acquired" in the log. Any other test that starts workers in the same process slows worker startup enough to hit this.
init() stored the nine statVFS result keys in static Nan::Persistent handles and reset them on every load. Static handles are shared by every thread, but each handle belongs to the isolate that created it. When the addon loads in a second worker after the first has exited, Reset() frees a handle owned by an isolate that no longer exists, and V8 aborts with "Check failed: node->IsInUse()". The keys are now created with Nan::New() where the result object is built, so no handle outlives the isolate that made it. tests/worker-reload-test.js loads the addon in the main thread and then in 20 workers one after another, collecting garbage after each exits. Before this change it aborts with the check above; after it, it passes. npm test passes (75 tests).
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.
Follow-up to #109.
Loading
fs-extin a worker after an earlier worker has exited can crash Node. The staticNan::Persistenthandles for statVFS property names belong to the old worker's V8 isolate, and the next load tries to reset them after that isolate is gone.This creates the property names when building each statVFS result. The regression loads the addon in the main thread, then in 20 workers one after another. The existing worker test also leaves log cleanup to the main thread, since a late-starting worker could delete its output.
The CI steps pass on Linux with Node 18.20.8, 20.20.2 and 22.23.5, including all 75 tests. The new regression fails with the old
fs-ext.cc. Lint reports the same 17 warnings as master, with no errors.