[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
Garbage Collection Riddle
- To: <xtech@xxxxxxxxxxx>
- Subject: Garbage Collection Riddle
- From: Mark S. Miller <vlad!mark>
- Date: Wed, 18 Jul 90 19:26:41 PDT
What's wrong with the following code?
Hint #1: It has to do with garbage collection.
LEAF int zip ();
LEAF void zap ();
LEAF int zorch (Foo * foo);
int Foo::zip ()
return myBar->zorch (this);
void Foo::zap ()
myBar = new Bar();
Bar::zorch (Foo * foo)
Hint #2: Why does zorch need to call zap twice to encounter the
Hint #3: A similar problem happens with naive purging schemes.
Hint #4: I see *no way* to fix the garbage collector so the above code
Hint #5: I think it would be very difficult to have XLint spot the
problem in the above code.
If you're thinking "Gee, that's an amazingly normal/safe/vanilla
looking piece of code for there to be anything seriously broken",
you're correct. That's why it's a serious problem.
I will postpone answering long enough for everyone to give it a shot.