Hi Steffen,

I know there is a similiar bug in plain perl 5.8.7. Sorry I could not find any 
of these post as I currently have few time.
On plain perl 5.10 the bug is for sure corrected as I am using it. I do not now 
for other perl versions.

Could this be related to your problem ?

Kind regards,

Jean-Philippe


-----Original Message-----
From: Steffen Mueller [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 25, 2008 12:19 PM
To: [email protected]
Subject: wxPerl + threads + join = crash

Hi wxPerl people,

thanks for the great toolkit. It's mostly a joy to work with.

Unfortunately, I'm experiencing problems with wxPerl in a threaded application. 
Essentially, I wrote a background task manager that pools threads. After a 
period of high load, it may terminate (Thread::Queue) and join a couple of 
threads to reduce the memory load.

The problem seems to be similar to what's been described here:
http://www.nntp.perl.org/group/perl.wxperl.users/2008/07/msg5961.html

Now, the application at hand is Padre. Gabor's been posting about it before, I 
assume. I'll outline some details I found out while trying to debug this and 
then explain how you can reproduce the problem using the Padre code. 
Unfortunately, I have no simple example code that exhibits the issues.

- I have read and understood Wx::Thread.
- I am loading threads and threads::shared before Wx.
- If you create threads before loading Wx, you can join them at any time 
without a crash.
- If you create threads after creating the GUI, then join one thread, you get a 
Scalars leaked: 1.
- If you join a second thread, the program simply exits.
- The complexity of the threads doesn't matter. Using "threads->create(sub{warn 
"Hi!"})" is sufficient.

Here's how you can reproduce the crashes:

- $ svn checkout
http://svn.perlide.org/padre/branches/padre-with-backgroundthreads
- cd there
- Run Build.PL to check for the dependencies; install them.
- Run dev.pl to launch the application.
Every two seconds, you will see output like "--1 at 
/home/tsee/padre/branches/padre-with-backgroundthreads/lib/Padre/TaskManager.pm
line 157.". It means there's one worker thread being held available.
- Enable the ThreadTest plugin via Plugins->Plugin Manager
- Run Plugins->Thread Test->Test
This will submit 20 or so short jobs to the taskmanager which will see large 
demand and spawn more threads. When the short jobs are done The --X numbers 
will go up quickly and you'll see "in task" warnings from the tasks themselves 
as they're processed. When they're through, you'll see something like this:

8 at ... line 94.
--8 at ... line 144.
--8 at ... line 157.
THREAD TERMINATING at ... line 272.

==> The above warning is from the worker thread which acknowledges that it's 
being shut down. It simply does a "return 1".

8 at ...line 94.
--8 at ... line 144.
Joining thread 3 at ... line 148.

==> This is from right before "$thread->join()" is called

Scalars leaked: 1

==> This is from that call.

joined at ... line 150.

==> This is from right after the call. Now, observe what happens with the 
second thread that's being joined:

--7 at ... line 157.
THREAD TERMINATING at ... line 272.
7 at ... line 94.
--7 at ... line 144.
Joining thread 1 at ... line 148.


And then you're back to the shell.

I really don't know how to fix this. Any help would be great. I understand it's 
likely an issue in the C++ part of WxPerl or wxWidgets.
Any pointer with regards to how *I* can debug that would be appreciated as well.

Best regards,
Steffen

Reply via email to