RE: Activeperl 5.10 + thread + join = random crashes

2009-06-03 Thread Jean-Philippe.Ulpiano
To be honnest I do not call any Tk lib. I even do not know why it appears in 
the stack ...

My C code uses wxWidgets lib for the GUI, hence the Perl side is used only for 
computation or some lowlevel accesses...

Thanks for your help,
Any other hint or idea will be welcome,

Jean-Philippe

 

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Brian 
Raven
Sent: Wednesday, June 03, 2009 4:05 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: RE: Activeperl 5.10 + thread + join = random crashes

jean-philippe.ulpi...@infineon.com
<mailto:jean-philippe.ulpi...@infineon.com> wrote: 
> Hi Brian,
> 
> Thanks for your reply,
> 
> Sorry, I should have specified that these crashes are sporadic.
> Sometimes it does not crash at all but when it crashes, it is usually 
> maximum after 15 join.
> 
> Hence it is hard to provide a piece of code to reproduce the problem.
> 
> Another thing I should have mentioned is that I am using embedded 
> perl. A C function performs a call in perl which starts a new thread.
> 
> Do you know if such behaviour is known by perl ?
> 
> FYI, here is a stack that I could get after one crash:
> I print a debug info specifying how many join were already done + that 
> a join is being done.
> Right after the join I print another info to specify that the join is 
> done.
> 
> 
> Join trial= 4
> Trying to join thread threadedRunRegressionTest0 $VAR1 = bless( 
> do{\(my $o = '83144192')}, 'Thread' );
> 
> [New LWP 8]
> [LWP 8 exited]
> [New LWP 8]
> [New LWP 9]
> [LWP 9 exited]
> [New LWP 9]
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to LWP 3]
> 0x000c in ?? ()
> (gdb) #0  0x000c in ?? ()
> #1  0xfb5b2648 in TclObj_free ()
>from
>
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/site
/lib/auto/Tk/Tk.so

Interesting that this is at the top of your stack. You are aware that Tk is not 
thread safe?

Of course that may not be your problem, but it is a pretty good candidate. In 
fact Tk can be used in a threaded Perl program, but it must be done with great 
care.

HTH

--
Brian Raven
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Activeperl 5.10 + thread + join = random crashes

2009-06-03 Thread Brian Raven
jean-philippe.ulpi...@infineon.com
 wrote: 
> Hi Brian,
> 
> Thanks for your reply,
> 
> Sorry, I should have specified that these crashes are sporadic.
> Sometimes it does not crash at all but when it crashes, it is usually
> maximum after 15 join.  
> 
> Hence it is hard to provide a piece of code to reproduce the problem.
> 
> Another thing I should have mentioned is that I am using embedded
> perl. A C function performs a call in perl which starts a new thread. 
> 
> Do you know if such behaviour is known by perl ?
> 
> FYI, here is a stack that I could get after one crash:
> I print a debug info specifying how many join were already done +
> that a join is being done. 
> Right after the join I print another info to specify that the join is
> done. 
> 
> 
> Join trial= 4
> Trying to join thread threadedRunRegressionTest0 $VAR1 = bless(
> do{\(my $o = '83144192')}, 'Thread' ); 
> 
> [New LWP 8]
> [LWP 8 exited]
> [New LWP 8]
> [New LWP 9]
> [LWP 9 exited]
> [New LWP 9]
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to LWP 3]
> 0x000c in ?? ()
> (gdb) #0  0x000c in ?? ()
> #1  0xfb5b2648 in TclObj_free ()
>from
>
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/site
/lib/auto/Tk/Tk.so

Interesting that this is at the top of your stack. You are aware that Tk
is not thread safe?

Of course that may not be your problem, but it is a pretty good
candidate. In fact Tk can be used in a threaded Perl program, but it
must be done with great care.

HTH

-- 
Brian Raven 
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Activeperl 5.10 + thread + join = random crashes

2009-06-03 Thread Jean-Philippe.Ulpiano
Hi Brian,

Thanks for your reply,

Sorry, I should have specified that these crashes are sporadic. Sometimes it 
does not crash at all but when it crashes, it is usually maximum after 15 join.

Hence it is hard to provide a piece of code to reproduce the problem.

Another thing I should have mentioned is that I am using embedded perl. A C 
function performs a call in perl which starts a new thread.

Do you know if such behaviour is known by perl ?

FYI, here is a stack that I could get after one crash:
I print a debug info specifying how many join were already done + that a join 
is being done.
Right after the join I print another info to specify that the join is done. 


Join trial= 4
Trying to join thread threadedRunRegressionTest0 $VAR1 = bless( do{\(my $o = 
'83144192')}, 'Thread' );

[New LWP 8]
[LWP 8 exited]
[New LWP 8]
[New LWP 9]
[LWP 9 exited]
[New LWP 9]

Program received signal SIGSEGV, Segmentation fault.
[Switching to LWP 3]
0x000c in ?? ()
(gdb) #0  0x000c in ?? ()
#1  0xfb5b2648 in TclObj_free ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/site/lib/auto/Tk/Tk.so
#2  0xfe717b84 in Perl_mg_free ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#3  0xfe748670 in Perl_sv_clear ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#4  0xfe748d40 in Perl_sv_free2 ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#5  0xfe7295b0 in Perl_av_undef ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#6  0xfe748820 in Perl_sv_clear ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#7  0xfe748d40 in Perl_sv_free2 ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#8  0xfe6ed250 in Perl_pad_undef ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#9  0xfe6e3a04 in Perl_cv_undef ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#10 0xfe7487d8 in Perl_sv_clear ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#11 0xfe748d40 in Perl_sv_free2 ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#12 0xfe6afad4 in Perl_gp_free ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#13 0xfe74898c in Perl_sv_clear ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#14 0xfe748d40 in Perl_sv_free2 ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#15 0xfe725928 in Perl_hv_free_ent ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#16 0xfe726128 in S_hfreeentries ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#17 0xfe7262c8 in Perl_hv_undef ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#18 0xfe7487f8 in Perl_sv_clear ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#19 0xfe748d40 in Perl_sv_free2 ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#20 0xfe6afabc in Perl_gp_free ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#21 0xfe74898c in Perl_sv_clear ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#22 0xfe748d40 in Perl_sv_free2 ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so
#23 0xfe740244 in S_visit ()
   from 
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/lib/CORE/libperl.so

   ...

#35 0xfe97564c in wxThreadInternal::PthreadStart ()
   from /home/swmdev/solaris/rel/lib/libwx_base-2.8.so.0.5.0
#36 0xfd77b138 in _thread_start () from /usr/lib/libthread.so.1
#37 0xfd77b138 in _thread_start () from /usr/lib/libthread.so.1
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) quit
The program is running.  Exit anyway? (y or n) [answered Y; input not from 
terminal]

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Brian 
Raven
Sent: Wednesday, June 03, 2009 2:14 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: RE: Activeperl 5.10 + thread + join = random crashes

jean-philippe.ulpi...@infineon.com <> wrote:
> Hi,
>
> I am using threads and perl and after a particular number of thread
> creation/destruction (2 to 15) perl crashes when doing a j

RE: Activeperl 5.10 + thread + join = random crashes

2009-06-03 Thread Brian Raven
jean-philippe.ulpi...@infineon.com <> wrote:
> Hi,
> 
> I am using threads and perl and after a particular number of thread
> creation/destruction (2 to 15) perl crashes when doing a join. 
> 
> I saw a similar problem dated from July 2004:
> http://aspn.activestate.com/ASPN/Mail/Message/perl-win32-users/2131329
> 
> Any idea if I am facing the same problem on Perl 5.10 ?
> Any idea if there is any workaround ?

Perhaps you could provide more detail. A small example script that
demonstrates the problem would be good.

For example, the following script, which creates a lot more than 15
threads, has run to completion on my box every time so far (Activestate
Perl 5.10.0 build 1004, on XP):

use strict;
use warnings;

use threads;
my $at_a_time = 20;
for (1..10) {
print "--\n";
print "Iteration $_\n";
for (1..$at_a_time) {
my $thr = threads->create(\&threadsub);
}
print "Waiting for threads to finish\n";
while (threads->list(threads::all) > 0) {
foreach my $thr (threads->list(threads::joinable)) {
my $result = $thr->join();
my $id = $thr->tid();
print "Result for thread $id is $result\n";
}
select undef, undef, undef, 0.1;
}
print "All threads finished\n";
}

sub threadsub {
my $id = threads->tid();
print "Thread $id starting\n";
my $delay = int(rand(5)) + 1;
sleep $delay;
print "Thread $id terminating\n";
return $delay;
}

HTH

-- 
Brian Raven 
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs