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

Re: 5.8.1@19053: threads goofs

Thread Previous | Thread Next
From:
Jarkko Hietaniemi
Date:
April 3, 2003 06:30
Subject:
Re: 5.8.1@19053: threads goofs
Message ID:
20030403143007.GD14115@vipunen.hut.fi
> 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.

Yup.  perl_destruct() is currently the only caller of Perl_ithread_hook()
(via PL_threadhook), and it's Perl_ithread_hook() the warning is emanating
from.

Also, "exit()ed or die()d" is wrong since the "main thread" 'falling
off the end' while there are still other running threads also gives
the warning.  So one does not need an explicit exit().  It's all about
a thread, any thread, calling it the day and bringing down all other
threads with it, too.

With a small tweak to pp_exit() I can get the message to be given also
for exit()ing "non-main" threads.

Die()ing is a slightly different matter, at least when doing testing
like this with just a single immediate call to die(), since it dies so
"fast" that threads->new() thinks the thread creation failed.

> 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.

Based on my quick testing, yes.

-- 
Jarkko Hietaniemi <jhi@iki.fi> http://www.iki.fi/jhi/ "There is this special
biologist word we use for 'stable'.  It is 'dead'." -- Jack Cohen

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