chrestomanci has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|