develooper Front page | perl.perl5.porters | Postings from January 2004

Re: threads::shared::queue;

Thread Previous | Thread Next
From:
Jan Dubois
Date:
January 22, 2004 19:22
Subject:
Re: threads::shared::queue;
Message ID:
fi41105602ds7a9o4fko2oae7aokbg6als@4ax.com
On Thu, 22 Jan 2004 18:23:07 -0800, Jan Dubois <jand@ActiveState.com> wrote:


>I've attached what I think is the correct patch to fix the problem of
>detached threads crashing on exit (at least on Windows).  The patch was
>created (and tested) against 5.8.3, but should be applied to bleadperl.

Oops, the patch was wrapped.  This is the correct one.

>Cheers,
>-Jan

--- threads.xs.orig	Thu Jan 22 16:35:40 2004
+++ threads.xs	Thu Jan 22 16:41:39 2004
@@ -93,6 +93,7 @@
 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 @@
 
 	    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);
 }


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About