mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
worker: fix crash when SharedArrayBuffer outlives creating thread
Keep a reference to the `ArrayBuffer::Allocator` alive for at least as long as a `SharedArrayBuffer` allocated by it lives. Refs: https://github.com/nodejs/node/pull/28788 Fixes: https://github.com/nodejs/node/issues/28777 Fixes: https://github.com/nodejs/node/issues/28773 PR-URL: https://github.com/nodejs/node/pull/29190 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
1 parent
c5edeb9776
commit
d4e397a900
6 files changed
+83
-9
No files matched your search
@@ -46,7 +46,9 @@ class SharedArrayBufferMetadata
|
||||
SharedArrayBufferMetadata(const SharedArrayBufferMetadata&) = delete;
|
||||
|
||||
private:
|
||||
explicit SharedArrayBufferMetadata(const v8::SharedArrayBuffer::Contents&);
|
||||
SharedArrayBufferMetadata(
|
||||
const v8::SharedArrayBuffer::Contents&,
|
||||
std::shared_ptr<v8::ArrayBuffer::Allocator>);
|
||||
|
||||
// Attach a lifetime tracker object with a reference count to `target`.
|
||||
v8::Maybe<bool> AssignToSharedArrayBuffer(
|
||||
@@ -55,6 +57,7 @@ class SharedArrayBufferMetadata
|
||||
v8::Local<v8::SharedArrayBuffer> target);
|
||||
|
||||
v8::SharedArrayBuffer::Contents contents_;
|
||||
std::shared_ptr<v8::ArrayBuffer::Allocator> allocator_;
|
||||
};
|
||||
|
||||
} // namespace worker
|
||||
|
||||
Reference in new issue
Block a user