Re: threads::shared::queue;
Jan Dubois [Thu, 22 Jan 2004 19:18:46 +0000 (11:18 -0800)]
Message-Id:  <fi41105602ds7a9o4fko2oae7aokbg6als@4ax.com>

Avoid threads+win32 crash by freeing Perl interpreter slightly later

p4raw-id: //depot/perl@22201

ext/threads/threads.xs

index 48530fe..9d4b2bb 100755 (executable)
@@ -93,6 +93,7 @@ ithread* Perl_ithread_get (pTHX) {
 void
 Perl_ithread_destruct (pTHX_ ithread* thread, const char *why)
 {
+        PerlInterpreter *freeperl = NULL;
        MUTEX_LOCK(&thread->mutex);
        if (!thread->next) {
            Perl_croak(aTHX_ "panic: destruct destroyed thread %p (%s)",thread, why);
@@ -144,12 +145,14 @@ Perl_ithread_destruct (pTHX_ ithread* thread, const char *why)
 
            thread->params = Nullsv;
            perl_destruct(thread->interp);
-            perl_free(thread->interp);
+            freeperl = thread->interp;
            thread->interp = NULL;
        }
        MUTEX_UNLOCK(&thread->mutex);
        MUTEX_DESTROY(&thread->mutex);
         PerlMemShared_free(thread);
+        if (freeperl)
+            perl_free(freeperl);
 
        PERL_SET_CONTEXT(aTHX);
 }