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


In reply to threads->new falling in a heap. by Steve_BZ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.