[pypy-commit] stmgc use-gcc: just a test showing that entries may stay alive (gc-wise) but get thrown out of the hashtable
Raemi
noreply at buildbot.pypy.org
Tue Sep 8 14:38:13 CEST 2015
Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: use-gcc
Changeset: r1955:c2f312c07ed8
Date: 2015-09-08 14:42 +0200
http://bitbucket.org/pypy/stmgc/changeset/c2f312c07ed8/
Log: just a test showing that entries may stay alive (gc-wise) but get
thrown out of the hashtable
diff --git a/c8/stm/hashtable.c b/c8/stm/hashtable.c
--- a/c8/stm/hashtable.c
+++ b/c8/stm/hashtable.c
@@ -180,6 +180,8 @@
char *to_read_from = segment_base;
if (segnum != -1) {
/* -> compaction during major GC */
+ /* it's possible that we just created this entry, and it wasn't
+ touched in this segment yet. Then seg0 is up-to-date. */
to_read_from = get_page_status_in(segnum, (uintptr_t)entry / 4096UL) == PAGE_NO_ACCESS
? stm_object_pages : to_read_from;
if (((struct stm_hashtable_entry_s *)
@@ -359,7 +361,7 @@
uintptr_t key)
{
stm_hashtable_entry_t *e = stm_hashtable_lookup(hobj, hashtable, key);
- stm_read((object_t *)e);
+ // stm_read((object_t *)e); - done in _lookup()
return e->object;
}
diff --git a/c8/test/test_hashtable.py b/c8/test/test_hashtable.py
--- a/c8/test/test_hashtable.py
+++ b/c8/test/test_hashtable.py
@@ -423,6 +423,38 @@
stm_major_collect()
self.commit_transaction()
+ def test_empty_entry_not_kept_alive(self):
+ self.start_transaction()
+ h = self.allocate_hashtable()
+ self.push_root(h)
+ stm_minor_collect()
+ h = self.pop_root()
+ self.push_root(h)
+
+ # produce some entries so we get compaction in major GC
+ K = 300
+ for i in range(K):
+ hashtable_lookup(h, get_hashtable(h), i)
+
+ entry = hashtable_lookup(h, get_hashtable(h), K)
+ self.push_root(entry)
+
+ self.commit_transaction()
+ self.start_transaction()
+
+ stm_major_collect() # compaction and rehashing
+
+ entry = self.pop_root()
+ entry2 = hashtable_lookup(h, get_hashtable(h), K)
+ assert entry != entry2
+
+ # get rid of ht:
+ self.pop_root()
+ self.commit_transaction()
+ self.start_transaction()
+ stm_major_collect()
+ self.commit_transaction()
+
More information about the pypy-commit
mailing list