On Tuesday 08 January 2008 10:34:47 Jeff Horwitz wrote: > After creating a new interpreter with Parrot_new(NULL) and destroying it > with Parrot_really_destroy(), a second call to Parrot_new(NULL) segfaults. > Parrot_really_destroy() should reset things so we can call Parrot_new() > without a parent interpreter again, as if we were starting from scratch. > > The attached patch augments t/src/extend.t to test this condition. It > currently fails with a segfault. The backtrace follows:
This was tricky. The problem is that nothing cleared singleton PMC pointers. Though Parrot_really_destroy() is good about clearing all arenas and freeing all allocated global memory, it doesn't wipe out several static variables. They retained their pointer values between worlds but pointed to the wrong places and thus corrupted vtables, at least on my machines, when initializing class PMCs. For now, I've added class_init() code to the five or six PMCs with singletons (and a special case for PMCNULL) so that whenever Parrot creates a new parent interpreter and initializes the world, each singleton PMC explicitly sets its static variable to NULL (see r24844). I also had to clear some thread global data in similar circumstances. There's one small thing that might be a hack in pt_gc_wakeup_check(), but I'm not sure that it gets called at the right time anyway per my reading of thread_func(), so I won't whine (r24845). This let me commit your patch as r24846. Thanks, -- c