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

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

Thread Previous | Thread Next
Nick Ing-Simmons
November 19, 2003 03:07
Re: need your help to do some (simple?) patching
Message ID:
Jan Dubois <> writes:
>On Mon, 17 Nov 2003 11:02:49 +0000, Nick Ing-Simmons
><> 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
>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...


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About