Skip to content

Commit 42dedb5

Browse files
aamCommit Bot
authored and
Commit Bot
committed
[vm/types] Ensure type arguments canonicalization doesn't race with readers.
Fixes #47140 TEST=ci, stress bot Change-Id: I0df3eab99754224344da9a18b8b4b2748e45a8b6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237761 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent 0d28233 commit 42dedb5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

runtime/vm/object.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6908,6 +6908,8 @@ TypeArgumentsPtr TypeArguments::Canonicalize(Thread* thread,
69086908
if (result.IsNull()) {
69096909
// Canonicalize each type argument.
69106910
AbstractType& type_arg = AbstractType::Handle(zone);
6911+
GrowableHandlePtrArray<const AbstractType> canonicalized_types(zone,
6912+
num_types);
69116913
for (intptr_t i = 0; i < num_types; i++) {
69126914
type_arg = TypeAt(i);
69136915
type_arg = type_arg.Canonicalize(thread, trail);
@@ -6916,7 +6918,7 @@ TypeArgumentsPtr TypeArguments::Canonicalize(Thread* thread,
69166918
ASSERT(IsRecursive());
69176919
return this->ptr();
69186920
}
6919-
SetTypeAt(i, type_arg);
6921+
canonicalized_types.Add(type_arg);
69206922
}
69216923
// Canonicalization of a type argument of a recursive type argument vector
69226924
// may change the hash of the vector, so invalidate.
@@ -6931,6 +6933,9 @@ TypeArgumentsPtr TypeArguments::Canonicalize(Thread* thread,
69316933
// canonical entry.
69326934
result ^= table.GetOrNull(CanonicalTypeArgumentsKey(*this));
69336935
if (result.IsNull()) {
6936+
for (intptr_t i = 0; i < num_types; i++) {
6937+
SetTypeAt(i, canonicalized_types.At(i));
6938+
}
69346939
// Make sure we have an old space object and add it to the table.
69356940
if (this->IsNew()) {
69366941
result ^= Object::Clone(*this, Heap::kOld);

0 commit comments

Comments
 (0)