Skip to content

Commit 623b5f8

Browse files
author
Joel Dice
committed
fix GC-in-hashMapResize bug which occasionally resulted in corrupt Machine::monitorMap
1 parent 9c82bd2 commit 623b5f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/util.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
301301

302302
newArray = makeArray(t, newLength, true);
303303

304+
if (oldArray != hashMapArray(t, map)) {
305+
// a resize was performed during a GC via the makeArray call
306+
// above; nothing left to do
307+
return;
308+
}
309+
304310
if (oldArray) {
305311
bool weak = objectClass(t, map)
306312
== arrayBody(t, t->m->types, Machine::WeakHashMapType);
@@ -320,7 +326,6 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
320326

321327
unsigned index = hash(t, k) & (newLength - 1);
322328

323-
expect(t, p != arrayBody(t, newArray, index));
324329
set(t, p, TripleThird, arrayBody(t, newArray, index));
325330
set(t, newArray, ArrayBody + (index * BytesPerWord), p);
326331
}
@@ -387,7 +392,6 @@ object
387392
hashMapRemoveNode(Thread* t, object map, unsigned index, object p, object n)
388393
{
389394
if (p) {
390-
expect(t, p != tripleThird(t, n));
391395
set(t, p, TripleThird, tripleThird(t, n));
392396
} else {
393397
set(t, hashMapArray(t, map), ArrayBody + (index * BytesPerWord),

0 commit comments

Comments
 (0)