[handles] DCHECK that thread isn't parked when creating handles

Parked threads are not allowed to create new handles or access the heap
in any other way. This is a pretty fundamental invariant of our
safepoint mechanism, which doesn't stop parked threads.

Change-Id: I577dbeffbb70e0843644cdc12ffbef022890c364
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3324542
Auto-Submit: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78316}
This commit is contained in:
Dominik Inführ 2021-12-09 07:07:39 +01:00 committed by V8 LUCI CQ
parent f668e9f7ae
commit 35ae63443b
2 changed files with 2 additions and 0 deletions

View File

@ -178,6 +178,7 @@ Address* HandleScope::CreateHandle(Isolate* isolate, Address value) {
Address* HandleScope::GetHandle(Isolate* isolate, Address value) {
DCHECK(AllowHandleAllocation::IsAllowed());
DCHECK(isolate->main_thread_local_heap()->IsRunning());
DCHECK_WITH_MSG(isolate->thread_id() == ThreadId::Current(),
"main-thread handle can only be created on the main thread.");
HandleScopeData* data = isolate->handle_scope_data();

View File

@ -16,6 +16,7 @@ namespace internal {
// static
V8_INLINE Address* LocalHandleScope::GetHandle(LocalHeap* local_heap,
Address value) {
DCHECK(local_heap->IsRunning());
if (local_heap->is_main_thread())
return LocalHandleScope::GetMainThreadHandle(local_heap, value);