Greeting wise brothers.

I am experiencing a problem debugging code that uses threads and LWP::UserAgent. I have reduced my failing code to this snippet:

#!/usr/bin/perl # Setup Pragmas. use strict; use warnings; use threads; use HTTP::Request; use LWP::UserAgent; sub main () { print "Starting a thread to find all SHAs \n"; threads->create( sub{ findAndQ_sha() } )->detach(); print "This line should be reached without error messages.\n"; return 0; } sub findAndQ_sha { print "Worker thread findAndQ_sha() running.\n"; sleep 1_000_000_000; # For testing, sleep for a long time. return; } exit main();

If in the debugger, I attempt to step over the line where the thread is created, I get an error: Thread 1 terminated abnormally: Undefined subroutine &Devel::CLONE called at demoLWP_threadBug.pl line 13. and a breakpoint in the findAndQ_sha() function is not reached. If I run without the debugger the script runs normally.

I am testing with perl 5.12.4 on Ubuntu Oneiric Linux, AMD64

If I comment out the use HTTP::Request; and use LWP::UserAgent; lines, then the code runs correctly in the debugger.

The script I am working on is using a Thread_pool design pattern. One thread is created to populate a queue of URLs that need fetching and processing, and a number of other worker threads are created to read from the queue and process each URL in turn. In the full (non reduced) version of the script, the package where the undefined CLONE subroutine was searched for varies.

Can anyone shed any light on this problem? is it a bug in LWP?


In reply to Abnormal exit with threads, LWP and the Perl Debugger by chrestomanci

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.