threads crash on XP (in Tk script)

M

MoshiachNow

HI,

Running a Tk script on my XP I always get an error.

Code:
########################################################################################
#use warnings;
use strict;
use Win32::OLE qw( in );
use Win32::Lanman;
use Net::Domain qw(hostname hostfqdn hostdomain);
use Socket 'inet_ntoa';
use Sys::Hostname 'hostname';
use Data::Validate::IP qw(is_ipv4);
use Net::ping;
use Tk;
use Tk::Text;
use Tk::Scrollbar;
use Tk::pane;
use threads;

threads->create(sub { print("I am a thread\n"); })->join();

Error:
I am a thread
Free to wrong pool 1822b00 not 222770 during global destruction.

Any ideas?
Thanks
 
B

Brian Raven

MoshiachNow said:
HI,

Running a Tk script on my XP I always get an error.

Code:
########################################################################################
#use warnings;
use strict;
use Win32::OLE qw( in );
use Win32::Lanman;
use Net::Domain qw(hostname hostfqdn hostdomain);
use Socket 'inet_ntoa';
use Sys::Hostname 'hostname';
use Data::Validate::IP qw(is_ipv4);
use Net::ping;
use Tk;
use Tk::Text;
use Tk::Scrollbar;
use Tk::pane;
use threads;

threads->create(sub { print("I am a thread\n"); })->join();

Error:
I am a thread
Free to wrong pool 1822b00 not 222770 during global destruction.

Any ideas?

One idea would be that threads, and modules that are not thread safe
do not mix very well. I don't know about any of the other modules that
you use, but Tk is not thread safe.

HTH
 
Z

zentara

One idea would be that threads, and modules that are not thread safe
do not mix very well. I don't know about any of the other modules that
you use, but Tk is not thread safe.

HTH

Yeah, but he has not invoked any Tk statements before he builds the
thread. It should work, and it does work fine on linux.

Tk will work fine with threads, IF you build the thread before invoking
any Tk statements, AND don't try to share objects across thread
boundaries.

But you are probably right, that one of the use statements is causing
it. I would try removing them all, and adding them back, 1 by 1, until
you find which one causes it.
 
B

Brian Raven

zentara said:
Yeah, but he has not invoked any Tk statements before he builds the
thread. It should work, and it does work fine on linux.

True, but I suspect that this is not real code, but a small example to
demonstrate the problem.
Tk will work fine with threads, IF you build the thread before invoking
any Tk statements, AND don't try to share objects across thread
boundaries.

Again true (I have done that myself), but those restrictions make it
more difficult to write decent code. Enough so that it is probably
better (IMHO) to consider alternative designs/modules first.
But you are probably right, that one of the use statements is causing
it. I would try removing them all, and adding them back, 1 by 1, until
you find which one causes it.

Which suggests that Tk is not the only thread unsafe module being
loaded. In which case, a single threaded approach may be less
problematic.

HTH
 
Z

zentara

Which suggests that Tk is not the only thread unsafe module being
loaded. In which case, a single threaded approach may be less
problematic.

HTH

Yeah, Tk is often blasted as not being thread safe, but many other
modules are in the same boat.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top