void
Perl_ithread_destruct (pTHX_ ithread* thread, const char *why)
{
+ PerlInterpreter* destroyperl = NULL;
MUTEX_LOCK(&thread->mutex);
if (!thread->next) {
Perl_croak(aTHX_ "panic: destruct destroyed thread %p (%s)",thread, why);
PERL_SET_CONTEXT(thread->interp);
SvREFCNT_dec(thread->params);
thread->params = Nullsv;
- perl_destruct(thread->interp);
- perl_free(thread->interp);
+ destroyperl = thread->interp;
thread->interp = NULL;
}
PERL_SET_CONTEXT(aTHX);
MUTEX_UNLOCK(&thread->mutex);
MUTEX_DESTROY(&thread->mutex);
PerlMemShared_free(thread);
+ if(destroyperl) {
+ perl_destruct(destroyperl);
+ perl_free(destroyperl);
+ }
}
int