Skip to content

Commit fa3ceb0

Browse files
author
Joel Dice
committed
add assertions to hashMapResize and hashMapRemove to help debug rare infinite loop
1 parent b1f2407 commit fa3ceb0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/util.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
321321

322322
unsigned index = hash(t, k) & (newLength - 1);
323323

324+
expect(t, p != arrayBody(t, newArray, index));
324325
set(t, p, TripleThird, arrayBody(t, newArray, index));
325326
set(t, newArray, ArrayBody + (index * BytesPerWord), p);
326327
}
@@ -333,7 +334,7 @@ hashMapResize(Thread* t, object map, uint32_t (*hash)(Thread*, object),
333334

334335
void
335336
hashMapInsert(Thread* t, object map, object key, object value,
336-
uint32_t (*hash)(Thread*, object))
337+
uint32_t (*hash)(Thread*, object))
337338
{
338339
// note that we reinitialize the array and index variables whenever
339340
// an allocation (and thus possibly a collection) occurs, in case
@@ -387,6 +388,7 @@ object
387388
hashMapRemoveNode(Thread* t, object map, unsigned index, object p, object n)
388389
{
389390
if (p) {
391+
expect(t, p != tripleThird(t, n));
390392
set(t, p, TripleThird, tripleThird(t, n));
391393
} else {
392394
set(t, hashMapArray(t, map), ArrayBody + (index * BytesPerWord),

0 commit comments

Comments
 (0)