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

Re: need your help to do some (simple?) patching

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
November 19, 2003 03:07
Subject:
Re: need your help to do some (simple?) patching
Message ID:
20031119105618.2752.8@llama.elixent.com
Jan Dubois <jand@ActiveState.com> writes:
>On Mon, 17 Nov 2003 11:02:49 +0000, Nick Ing-Simmons
><nick.ing-simmons@elixent.com> wrote:
>
>>>I recognize that this is Windows specific, but at least on Windows it is
>>>not safe to call PERL_GET_CONTEXT from a Window callback.  
>>
>>Which is why I don't claim even Tk804 to be thread ready yet.
>
>This is unrelated to threading.  I've seen crashes (of Win32::GUI, not Tk)
>in a singled threaded application, embedding just a single Perl
>interpreter.  The sequence of events was:
>
>* App sets context, calls into Perl
>* Perl code creates dialog
>* User terminates dialog
>* Perl returns to App
>* App restores context (to NULL, as there is no other interpreter)
>* Windows dispatches another message (WM_SETFOCUS) to the dialog
>* Dialog does PERL_GET_CONTEXT, sets context, calls into Perl and crashes
>
>A workaround here was to globally set the context once the Perl
>interpreter was created.  But the real bug was Win32::GUI calling
>PERL_GET_CONTEXT in a window procedure.  

The real bug is Windows sending messages to windows that no longer exist ;-)
I suspect though that it doesn't, and the bug is that Win32::GUI should 
have "waited" for an ACK of some kind before returning to caller.
(There are several of those in Tk's Win32 "window manager" code.)

>If the App had been switching
>between multiple interpreters, this workaround would not have been
>possible.
> 
>I don't know if this scenario is possible with Tk too; I just wanted to
>alert you that it is a potential source of problems.

Hmm, Tk may be vulnerable. The "plan" is to associate the context with 
the window (which isn't really correct for X, but Win32 windows seem to 
be associated with ONE thread?) or perhaps (window/threadid) pair.
But clearly Win32 is not going to pass callback perl's context without 
help. (Perhaps some user DWORD slot is available?)

Thanks for the warning - will copy this mail to my Tk ToDo folder...

>
>Cheers,
>-Jan


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