From 6d6afe13dab0ce7b6b3c35bdc10f02cd6f332f93 Mon Sep 17 00:00:00 2001 From: Andreas Woess Date: Wed, 28 Aug 2024 14:57:13 +0200 Subject: [PATCH] [GR-57654] Fix racy assertion for weak keys in TrieTransitionMap. --- .../src/com/oracle/truffle/object/TrieNode.java | 6 +----- .../src/com/oracle/truffle/object/UnorderedTrieMap.java | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/TrieNode.java b/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/TrieNode.java index f5fd27b4bf47..231960c43a32 100644 --- a/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/TrieNode.java +++ b/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/TrieNode.java @@ -393,9 +393,7 @@ E find(K key, int hash, int shift) { if (index < 0) { return null; } else { - E entry = (E) entries[index]; - assert entry != null && key(entry).equals(key) : Arrays.asList(entry, key); - return entry; + return (E) entries[index]; } } @@ -408,7 +406,6 @@ TrieNode put(K key, int hash, E entry, int shift) { return new HashCollisionNode<>(hash, copyAndAppend(entries, entry)); } else { E e = (E) entries[index]; - assert e != null && key(e).equals(key) : Arrays.asList(e, key); if (e.equals(entry)) { return this; } else { @@ -427,7 +424,6 @@ TrieNode remove(K key, int hash, int shift) { if (index < 0) { return this; } else { - assert entries[index] != null && key((E) entries[index]).equals(key) : Arrays.asList(entries[index], key); assert entries.length >= 2; if (entries.length == 2) { return new BitmapNode<>(bit(this.hashcode, shift), copyAndRemove(entries, index)); diff --git a/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/UnorderedTrieMap.java b/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/UnorderedTrieMap.java index 3a1e63ad12eb..145cbf8f8441 100644 --- a/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/UnorderedTrieMap.java +++ b/truffle/src/com.oracle.truffle.object/src/com/oracle/truffle/object/UnorderedTrieMap.java @@ -116,7 +116,7 @@ public V get(Object key) { Map.Entry getEntry(K key) { var entry = root.find(key, hash(key)); - assert entry == null || entry.getKey().equals(key) : Arrays.asList(entry, key); + assert entry == null || entry.getKey().equals(key) || (entry.getKey() instanceof WeakKey wk && wk.refersTo(null)) : Arrays.asList(entry, key); return entry; }