[vm, gc] Don't use Thread::sticky_error_ when aborting a scavenge.

TEST=tsan
Bug: https://github.com/dart-lang/sdk/issues/46095
Change-Id: I5c2695ec9a6a0d9fa1415805bc83a90fc1f8ee17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204820
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2021-06-28 18:06:12 +00:00 committed by commit-bot@chromium.org
parent f5b28a83e8
commit 206c7ba8a6
3 changed files with 13 additions and 8 deletions

View file

@ -219,7 +219,6 @@ class ScavengerVisitorBase : public ObjectPointerVisitor {
scavenger_->IterateRoots(this);
} else {
ASSERT(scavenger_->abort_);
thread_->ClearStickyError();
}
}
@ -233,7 +232,6 @@ class ScavengerVisitorBase : public ObjectPointerVisitor {
} while (HasWork());
} else {
ASSERT(scavenger_->abort_);
thread_->ClearStickyError();
}
}
@ -249,7 +247,6 @@ class ScavengerVisitorBase : public ObjectPointerVisitor {
} while (HasWork());
} else {
ASSERT(scavenger_->abort_);
thread_->ClearStickyError();
}
}
@ -475,7 +472,9 @@ class ScavengerVisitorBase : public ObjectPointerVisitor {
OS::PrintErr("Aborting scavenge\n");
}
scavenger_->abort_ = true;
thread_->long_jump_base()->Jump(1, Object::out_of_memory_error());
// N.B. We must not set the sticky error, which may be a data race if
// that root slot was processed by a different worker.
thread_->long_jump_base()->Jump(1);
}
inline void ProcessToSpace();

View file

@ -20,10 +20,18 @@ jmp_buf* LongJumpScope::Set() {
}
void LongJumpScope::Jump(int value, const Error& error) {
ASSERT(!error.IsNull());
// Remember the error in the sticky error of this isolate.
Thread::Current()->set_sticky_error(error);
Jump(value);
}
void LongJumpScope::Jump(int value) {
// A zero is the default return value from setting up a LongJumpScope
// using Set.
ASSERT(value != 0);
ASSERT(!error.IsNull());
Thread* thread = Thread::Current();
DEBUG_ASSERT(thread->TopErrorHandlerIsSetJump());
@ -35,9 +43,6 @@ void LongJumpScope::Jump(int value, const Error& error) {
#undef CHECK_REUSABLE_HANDLE
#endif // defined(DEBUG)
// Remember the error in the sticky error of this isolate.
thread->set_sticky_error(error);
// Destruct all the active StackResource objects.
StackResource::UnwindAbove(thread, top_);
longjmp(environment_, value);

View file

@ -30,6 +30,7 @@ class LongJumpScope : public StackResource {
jmp_buf* Set();
DART_NORETURN void Jump(int value, const Error& error);
DART_NORETURN void Jump(int value);
private:
jmp_buf environment_;