01-05-04 17.09, skrev Alan Burlison p� [EMAIL PROTECTED] f�ljande:

> Artur Bergman wrote:
> 
>> 01-05-04 16.28, skrev Alan Burlison p� [EMAIL PROTECTED] f�ljande:
>> 
>>> Artur Bergman wrote:
>>> 
>>>> Ouch.
>>> 
>>> Indeed.
>>> 
>>>> What is then the point of MULTIPLICITY and USEITHREAD? And isn't pseudo
>>>> forking on win32 which uses the same technique considerd stable?
>>>> (ActiveState perl does come with it enabled)
>>> 
>>> I really can't comment on what happens on Win32 - Sarathay is the person to
>>> ask there.  However on Solaris at least, the manpages for setjmp and longjmp
>>> say this:
>>> 
>>> ____________________________________________________________
>>> |       ATTRIBUTE TYPE        |       ATTRIBUTE VALUE       |
>>> |_____________________________|_____________________________|
>>> | MT-Level                    | Unsafe                      |
>>> |_____________________________|_____________________________|
>>> 
>>> The reason for the warning is that because setjmp/longjmp can potentially go
>>> from/to anywhere, it is impossible to be sure that you weren't holding a
>>> mutex, or sleeping on a condition variable before the longjmp.  The longjmp
>>> leaves the state of the application undefined with respect to the locks that
>>> are held.  This is especially the case where longjmp is used in conjunction
>>> with a signal handler.
>> 
>> From what I understand perl doesn't accquire any mutexes,lock,conditions
>> when running in separete threads using USEITHREAD. So this problem will only
>> exist with shared data between threads.
> 
> Not so.  If two ITHREADS both call a MT-unsafe library function (e.g.
> strtok()) then breakage will ensue.

What has this to do with longjmp/setjmp?

>> I tried looking at the src but I haven't learnt to properly navigate it, but
>> if perl does this on error handling, then the code that handles the sharing
>> must ensure not to call longjmp while it holds any mutex. If a user holds
>> any lock while his program handles error, then he must handle them aswell.
> 
> How?
> 

eval {
    lock($foo);
    die;
};
if($@) {
    #Make sure to unlock everything or you are toast
}

?

Artur

Reply via email to