On Wed, 10 Jul 2002 23:32:03 -0700, Jan Dubois <JanD@ActiveState.com> wrote: >On Thu, 11 Jul 2002 08:13:59 +0200, Arthur Bergman <arthur@contiller.se> >wrote: > >>The myperl that holds the function pointer gets freed by perl_free and >>then PerlMemShared_free is left on it its own, on unix >>PerlMemShared_free is just a simple safefree so it doesn't need the >>my_perl, nor does it happen on join since then the aTHX is the callee. >> >>Please try the following patch, > >Seems to solve the problem! I ran the test script 6 times without any >access violations. Pass it on to the "Thanks, applied!" crowd! :) I've just spent 2 hours hunting down a threading problem and ended up in the exact same corner again. I then checked both perl-latest and perl-5.8.x, and neither seem to include your patch. Any reason it didn't get committed? It looks like it may almost be too late to get it into Perl 5.8.3 now either. Cheers, -Jan >>--- /tmp/tmp.3471.0 Thu Jul 11 08:12:32 2002 >>+++ /Users/sky/perl/p4/ext/threads/threads.xs Thu Jul 11 08:09:52 2002 >>@@ -91,6 +91,7 @@ >> 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); >>@@ -127,14 +128,17 @@ >> 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); >>+ } >> } >> >> intThread Next