[pypy-commit] stmgc default: Potential bug: stmgc_size() can return a number smaller than needed
arigo
noreply at buildbot.pypy.org
Mon Jul 15 18:18:59 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r400:d609310cc4d0
Date: 2013-07-15 18:18 +0200
http://bitbucket.org/pypy/stmgc/changeset/d609310cc4d0/
Log: Potential bug: stmgc_size() can return a number smaller than needed
for a stub.
diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -1091,7 +1091,7 @@
#endif
L->h_revision = new_revision;
- gcptr stub = stm_stub_malloc(d->public_descriptor);
+ gcptr stub = stm_stub_malloc(d->public_descriptor, 0);
stub->h_tid = (L->h_tid & STM_USER_TID_MASK) | GCFLAG_PUBLIC
| GCFLAG_STUB
| GCFLAG_OLD;
diff --git a/c4/steal.c b/c4/steal.c
--- a/c4/steal.c
+++ b/c4/steal.c
@@ -1,11 +1,13 @@
#include "stmimpl.h"
-gcptr stm_stub_malloc(struct tx_public_descriptor *pd)
+gcptr stm_stub_malloc(struct tx_public_descriptor *pd, size_t minsize)
{
assert(pd->collection_lock != 0);
+ if (minsize < sizeof(struct stm_stub_s))
+ minsize = sizeof(struct stm_stub_s);
- gcptr p = stmgcpage_malloc(sizeof(struct stm_stub_s));
+ gcptr p = stmgcpage_malloc(minsize);
STUB_THREAD(p) = pd;
return p;
}
@@ -38,7 +40,8 @@
assert(stub->h_revision == (((revision_t)obj) | 2));
goto done;
- not_found:
+ not_found:;
+ size_t size = 0;
if (!obj->h_original && !(obj->h_tid & GCFLAG_OLD)) {
/* There shouldn't be a public, young object without
a h_original. But there can be priv/protected ones.
@@ -48,12 +51,9 @@
collection later. */
assert(!(obj->h_tid & GCFLAG_PUBLIC));
- stub = (gcptr)stmgcpage_malloc(stmgc_size(obj));
- STUB_THREAD(stub) = sd->foreign_pd;
+ size = stmgc_size(obj);
}
- else {
- stub = stm_stub_malloc(sd->foreign_pd);
- }
+ stub = stm_stub_malloc(sd->foreign_pd, size);
stub->h_tid = (obj->h_tid & STM_USER_TID_MASK) | GCFLAG_PUBLIC
| GCFLAG_STUB
| GCFLAG_OLD;
diff --git a/c4/steal.h b/c4/steal.h
--- a/c4/steal.h
+++ b/c4/steal.h
@@ -9,7 +9,7 @@
#define STUB_THREAD(h) (((struct stm_stub_s *)(h))->s_thread)
-gcptr stm_stub_malloc(struct tx_public_descriptor *);
+gcptr stm_stub_malloc(struct tx_public_descriptor *, size_t minsize);
void stm_steal_stub(gcptr);
gcptr stm_get_stolen_obj(long index); /* debugging */
void stm_normalize_stolen_objects(struct tx_descriptor *);
More information about the pypy-commit
mailing list