check hash table insertions
authorAlexandre Oliva <oliva@adacore.com>
Fri, 30 Dec 2022 16:44:50 +0000 (13:44 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 30 Dec 2022 16:44:50 +0000 (13:44 -0300)
commit012fdbc14233fbb463fd27a05493050d1b88aecf
tree9bdce03edf34e0a5679d4af059b1e818f3a2521e
parentebf7dd754a95bf9680bc53331a6b70f0cf83c045
check hash table insertions

I've noticed a number of potential problems in hash tables, of three
kinds: insertion of entries that seem empty, dangling insertions, and
lookups during insertions.

These problems may all have the effect of replacing a deleted entry
with one that seems empty, which may disconnect double-hashing chains
involving that entry, and thus cause entries to go missing.

This patch detects such problems by recording a pending insertion and
checking that it's completed before other potentially-conflicting
operations.  The additional field is only introduced when checking is
enabled.

for  gcc/ChnageLog

* hash-table.h (check_complete_insertion, check_insert_slot):
New hash_table methods.
(m_inserting_slot): New hash_table field.
(begin, hash_table ctors, ~hash_table): Check previous insert.
(expand, empty_slow, clear_slot, find_with_hash): Likewise.
(remote_elt_with_hash, traverse_noresize): Likewise.
(gt_pch_nx): Likewise.
(find_slot_with_hash): Likewise.  Record requested insert.
gcc/hash-table.h