Author: Remi Meier <remi.me...@gmail.com> Branch: Changeset: r479:c3bb5c223595 Date: 2013-08-15 18:19 +0200 http://bitbucket.org/pypy/stmgc/changeset/c3bb5c223595/
Log: fix embarrassing bug diff --git a/c4/et.c b/c4/et.c --- a/c4/et.c +++ b/c4/et.c @@ -1339,9 +1339,13 @@ and then free B, which will not be used any more. */ size_t size = stmgc_size(B); assert(B->h_tid & GCFLAG_BACKUP_COPY); + /* if h_original was 0, it must stay that way and not point + to itself. (B->h_original may point to P) */ + revision_t h_original = P->h_original; memcpy(((char *)P) + offsetof(struct stm_object_s, h_revision), ((char *)B) + offsetof(struct stm_object_s, h_revision), size - offsetof(struct stm_object_s, h_revision)); + P->h_original = h_original; assert(!(P->h_tid & GCFLAG_BACKUP_COPY)); stmgcpage_free(B); dprintf(("abort: free backup at %p\n", B)); diff --git a/c4/extra.c b/c4/extra.c --- a/c4/extra.c +++ b/c4/extra.c @@ -91,6 +91,8 @@ return (revision_t)p; } + assert(p->h_original != (revision_t)p); + dprintf(("stm_id(%p) has orig fst: %p\n", p, (gcptr)p->h_original)); return p->h_original; diff --git a/c4/nursery.c b/c4/nursery.c --- a/c4/nursery.c +++ b/c4/nursery.c @@ -175,6 +175,7 @@ stm_copy_to_old_id_copy(obj, id_obj); fresh_old_copy = id_obj; + fresh_old_copy->h_original = 0; obj->h_tid &= ~GCFLAG_HAS_ID; } else { diff --git a/c4/test/test_extra.py b/c4/test/test_extra.py --- a/c4/test/test_extra.py +++ b/c4/test/test_extra.py @@ -156,3 +156,17 @@ 0, 0, 0, 0, 0, 0] + +def test_bug(): + p1 = nalloc(HDR) + pid = lib.stm_id(p1) + lib.stm_push_root(p1) + minor_collect() + p1o = lib.stm_pop_root() + + assert p1o == ffi.cast("gcptr", pid) + assert follow_original(p1o) == ffi.NULL + + + + _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit