Skip to content

Commit d777f9e

Browse files
committed
Fix a segfault related to freeing of anonymous types. Note that we need a real fix for this issue, but it's relatively low impact for the time being.
1 parent 85011da commit d777f9e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/pmc/sixmodelobject.pmc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,18 @@ pmclass SixModelObject manual_attrs dynpmc group nqp {
3535
}
3636

3737
VTABLE void destroy() {
38-
/* Delegate to the representation. */
39-
REPR(SELF)->gc_free(interp, REPR_PMC(SELF), SELF);
38+
/* Delegate to the representation.
39+
* XXX There's a really nasty problem here. Since the GC provides no
40+
* promises about ordering, the s-table may get collected before the
41+
* last object pointing to it (a situation that arises when we have
42+
* anonymous types). That means the REPR - which knows how to free
43+
* the object - may be unreachable by the time we get here. Oops.
44+
* For now, just leak the type object memory. The current REPR
45+
* factoring is less than ideal in other ways too.
46+
*/
47+
STable *st = STABLE(SELF);
48+
if (st)
49+
REPR(SELF)->gc_free(interp, REPR_PMC(SELF), SELF);
4050
}
4151

4252
VTABLE PMC * find_method(STRING *name) {

0 commit comments

Comments
 (0)