develooper Front page | perl.perl5.porters | Postings from April 2003

Re: 5.8.1@19053: threads goofs

Thread Previous | Thread Next
From:
Tim Bunce
Date:
April 3, 2003 01:39
Subject:
Re: 5.8.1@19053: threads goofs
Message ID:
20030403093926.GA49493@dansat.data-plan.com
On Wed, Apr 02, 2003 at 12:39:09PM -0800, Ilya Zakharevich wrote:
> On Wed, Apr 02, 2003 at 01:07:05PM +0100, Tim Bunce wrote:
> > > This has nothing to do with detach()/join().  Reading the source
> > > shows: what the message tries to express (but as you can see it does
> > > not succeed) is that a thread requests the whole process to exit(),
> > > while this thread is not the last running thread of the process.
> > 
> > Not neccessarily "requests". It's just when an interpretter is being
> > destroyed by itself for whatever reason. Hence the very general
> > wording of "A thread exited".
> 
> IIUC: Nope.  The message is shown when *the process* terminates (via
> Perl-visible request), not "an interpreter terminates".

See below.

> > Seems like it is related to detach()/join() in that when a non-detached
> > thread terminates it effectively waits for another thread to join()
> > it to collect the result. And, as I understand it, the thread the
> > does the join() is the one that calls perl_destruct() and so the
> > "A thread exited" warning isn't generated (see the code).
> 
> Sorry, cannot parse what you wrote.  The message is shown when on the
> process termination there are non-joined or detached threads.  Process
> termination happens when a thread calls exit() or die()s (including
> implicit exit() at the end of the main program).

The Perl_ithread_hook() function generates the warning
if active_threads != 1 and aTHX == PL_curinterp (ie a thread is
destroying it's 'own' interpreter and not an interpreter created
for another thread).

The Perl_ithread_hook() function is only called by perl_destruct().
And perl_destruct() has no knowledge of why the interpreter is being
destroyed.o

There's nothing explicitly related to process termination here.
But process termination is when you're most likely to trigger it.

I imagine (but have no time to test) that it would also be triggered
if thread A starts a non-deteched thread B then thread A terminates
before thread B does. Thread B is left with no other thread to 'join'
to in order to get cleaned up so must perl_destruct it's own interpreter.

> Do not think this understanding of mine coincides with one of yours.
> And I have some trust intoamy understanding - I spend a long time
> trying to debug this message.

Perhaps. I certanly can't claim to have much experience of thread.
But if there is a flaw in my understanding I'd like it to be pointed out.

Tim.

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