Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys,
I have some issues here with threads->new. However, it only fails in Komodo IDE 5 and Kubuntu 11.10. If I run from the command prompt, everything is cool. If I run from Komodo in Kubuntu 10.04, also, everything is cool. I have an app that generates some background tasks like an email with some large attachments. I don't want to wait while it sends so sending is a background task. It works like this:
if ( ref $next_job eq "Mail::Sender"){ $gl_thread_hsh{$gl_thread_hsh{next_thread}} = threads->new +( sub { my $result = $next_job->MailFile({ msg => $next_job->{msg}, file => $next_job->{file}, }); } ); $gl_thread_hsh{next_thread}=$gl_thread_hsh{next_thread}+1; + # Increment next available thread. }
Everything then crashes with this sort of error message (I don't think you want my whole stack-dump):
*** glibc detected *** /usr/bin/perl: double free or corruption (out): + 0x00007fff69bf35e0 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x7a6e6)[0x7fb82e4f76e6] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7fb82e4fb9cc] /usr/local/lib/perl/5.12.4/auto/Wx/Wx.so(+0x172e3c)[0x7fb82c745e3c] /usr/lib/libperl.so.5.12(Perl_pp_entersub+0x54d)[0x7fb82e8ce46d] /usr/lib/libperl.so.5.12(Perl_runops_standard+0x20)[0x7fb82e8c5c10] /usr/lib/libperl.so.5.12(Perl_call_sv+0x473)[0x7fb82e869cc3] /usr/lib/libperl.so.5.12(Perl_sv_clear+0x27a)[0x7fb82e8d3c0a] /usr/lib/libperl.so.5.12(Perl_sv_free2+0x52)[0x7fb82e8d4422] /usr/lib/libperl.so.5.12(Perl_sv_clear+0x725)[0x7fb82e8d40b5] /usr/lib/libperl.so.5.12(Perl_sv_free2+0x52)[0x7fb82e8d4422] /usr/lib/libperl.so.5.12(Perl_av_clear+0x158)[0x7fb82e8c3f88] /usr/lib/libperl.so.5.12(Perl_pp_entersub+0x7b3)[0x7fb82e8ce6d3]
I have also tried replacing use threads at the start of the program with require threads at call time. This doesn't help. My real issue is that this creates a blind-spot for debugging, in that issues in this area of code can't properly be debugged by single stepping through the code and examining variables, but only by print statments.
What are your thoughts, please?
Regards
Steve
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: threads->new falling in a heap.
by BrowserUk (Patriarch) on May 11, 2012 at 11:39 UTC | |
by Steve_BZ (Chaplain) on May 11, 2012 at 12:17 UTC | |
by BrowserUk (Patriarch) on May 11, 2012 at 12:30 UTC | |
by Steve_BZ (Chaplain) on May 11, 2012 at 13:29 UTC | |
by BrowserUk (Patriarch) on May 11, 2012 at 14:23 UTC | |
|