Branch: Tag:

2003-03-30

2003-03-30 01:34:53 by Martin Stjernholm <mast@lysator.liu.se>

Fixed refcounting of the o->prog references in objects. Prior to this it was
possible to generate garbage that never was removed by the gc, but it
requires some resolver trickery (see test case) so it's unlikely to occur in
practice.

Rev: src/gc.c:1.211
Rev: src/object.c:1.231
Rev: src/testsuite.in:1.628

1: - test_true([["$Id: testsuite.in,v 1.627 2003/03/29 18:38:28 grubba Exp $"]]); + test_true([["$Id: testsuite.in,v 1.628 2003/03/30 01:34:53 mast Exp $"]]);      // This triggered a bug only if run sufficiently early.   test_compile_any([[#pike 7.2]])
4333:   test_do(add_constant("blatinka");)       test_any([[{ + #if constant (_debug) +  // Temporarily disable debug so we don't get references to p in +  // the intepreter backlog. +  int old_debug = _debug (0); + #endif +  object o = class {program p; object o;}(); +  class Resolver (mixed x) {mixed resolv (string id) {return x;}}; +  program p = compile ("constant o = foo;", Resolver (o)); +  o->p = p; +  o->o = p(); +  gc(); +  o = p = 0; + #if constant (_debug) +  _debug (old_debug); + #endif +  return gc() > 0; +  }]], 1) +  +  test_any([[{    class Dead {object o;};    object o = Dead(); o->o = Dead();    array a = set_weak_flag(({o}), 1);