Commit 3868e2ce authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

[strings] Use current isolate when externalizing shared strings

v8::String::MakeExternal is currently incorrectly using the shared
isolate of the shared string, which will race when setting VM state. In
general the shared Isolate shouldn't be used for anything, it's an
implementation detail to hold the shared heap space.

Bug: v8:12007, v8:13276
Fixed: v8:13276
Change-Id: I21ec57645ed4740a4c19c51b8fa1e2928a07a0f4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3888384Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83139}
parent 29aed83f
......@@ -7055,9 +7055,16 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
return false;
}
// It is safe to call GetIsolateFromWritableHeapObject because
// SupportsExternalization already checked that the object is writable.
i::Isolate* i_isolate = i::GetIsolateFromWritableObject(obj);
// TODO(v8:12007): Consider adding
// MakeExternal(Isolate*, ExternalStringResource*).
i::Isolate* i_isolate;
if (obj.IsShared()) {
i_isolate = i::Isolate::Current();
} else {
// It is safe to call GetIsolateFromWritableHeapObject because
// SupportsExternalization already checked that the object is writable.
i_isolate = i::GetIsolateFromWritableObject(obj);
}
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
CHECK(resource && resource->data());
......@@ -7081,9 +7088,16 @@ bool v8::String::MakeExternal(
return false;
}
// It is safe to call GetIsolateFromWritableHeapObject because
// SupportsExternalization already checked that the object is writable.
i::Isolate* i_isolate = i::GetIsolateFromWritableObject(obj);
// TODO(v8:12007): Consider adding
// MakeExternal(Isolate*, ExternalOneByteStringResource*).
i::Isolate* i_isolate;
if (obj.IsShared()) {
i_isolate = i::Isolate::Current();
} else {
// It is safe to call GetIsolateFromWritableHeapObject because
// SupportsExternalization already checked that the object is writable.
i_isolate = i::GetIsolateFromWritableObject(obj);
}
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
CHECK(resource && resource->data());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment