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 18:27
Subject:
Re: threads::shared::queue;
Message ID:
g311101cr4q944kqmnpqs0prsljsg1aljp@4ax.com
On Wed, 31 Dec 2003 11:19:58 -0800, Jan Dubois <jand@ActiveState.com>
wrote:

>It actually had been committed:
>
>http://public.activestate.com/cgi-bin/perlbrowse?patch=17476
>
>Unfortunately it has been backed out again:
>
>http://public.activestate.com/cgi-bin/perlbrowse?patch=18615
>
>And the original problem, of course, is back. :(

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.

Cheers,
-Jan

--- ext/threads.xs.orig	Thu Jan 22 16:35:40 2004
+++ ext/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