-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
worker: fix crash when SharedArrayBuffer outlives creating thread #28788
worker: fix crash when SharedArrayBuffer outlives creating thread #28788
Conversation
The two failures on other worker tests in CI might be related? |
@Trott I don’t know about |
Oh, yes, the I’ll figure out something for that. |
Use the parent thread’s `ArrayBuffer::Allocator` when creating a Worker instance, as that allocator is guaranteed to outlive the Worker itself. This requires making the zero-fill flag a thread_local variable in order to avoid race conditions between different threads. A test for that behaviour is added as well. Fixes: nodejs#28777 Fixes: nodejs#28773
446d7c5
to
14d4ad0
Compare
I’ve fixed that issue by now by using a thread_local but I’m not really happy with that as a solution … I’ll think about it a bit more. My ideal solution would be to turn the zero-fill field into an atomic counter and increasing/decreasing that from the threads, but I’m having a hard time thinking of a way to make it atomically accessible both from JS and C++. |
Good to land this in the meantime or you'd like to think on this bit some more? |
@Trott I strongly dislike this solution, and I’m still thinking about it … but haven’t been able to come up with somebody better so far. And hopefully, in the worst case we can get rid of it anyway when V8 removes ArrayBuffer::Allocator altogether in the future… |
AIX failure in CI is genuine? |
Hm … I’m assuming that it’s because of the |
Sorry it took me so long (the HTTP/2 security stuff got preference treatment here), but I came up with a solution that isn’t ideal either but definitely better than this and which should pass CI (→ #29190). I’ll close this PR as the code changes are completely different from the ones in this one. |
Keep a reference to the `ArrayBuffer::Allocator` alive for at least as long as a `SharedArrayBuffer` allocated by it lives. Refs: nodejs#28788 Fixes: nodejs#28777 Fixes: nodejs#28773
Keep a reference to the `ArrayBuffer::Allocator` alive for at least as long as a `SharedArrayBuffer` allocated by it lives. Refs: #28788 Fixes: #28777 Fixes: #28773 PR-URL: #29190 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Keep a reference to the `ArrayBuffer::Allocator` alive for at least as long as a `SharedArrayBuffer` allocated by it lives. Refs: #28788 Fixes: #28777 Fixes: #28773 PR-URL: #29190 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Use the parent thread’s
ArrayBuffer::Allocator
when creating aWorker instance, as that allocator is guaranteed to outlive the
Worker itself.
Fixes: #28777
Fixes: #28773
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes