Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Thread::Queue dies in debugger, runs without debugger (solved)

by yulivee07 (Sexton)
on Nov 01, 2017 at 10:05 UTC ( #1202503=perlquestion: print w/replies, xml ) Need Help??

yulivee07 has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow perlmonks, this morning I am trying to debug a program which is making use of Thread::Queue. Fortunately, the person who wrote it in the first place included an option "--debug" so the program does not use Threads, making debugging easier. However, I am encountering a problem which I currently have no clue how to tackle:

If I start the program in the debugger it blurts out error messages and dies:
perl -d ./program --debug ~/github/sbin/programconfig Loading DB routines from version 1.44 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. lock can only be used on shared values at /usr/opt/perl5/lib/5.20.1/pe line 4101. BEGIN failed--compilation aborted at /usr/opt/perl5/lib/5.20.1/Thread/ line 9. Compilation failed in require at ./program line 1156. BEGIN failed--compilation aborted at ./program line 1156. lock can only be used on shared values at /usr/opt/perl5/lib/5.20.1/pe line 4101. END failed--call queue aborted at ./program line 1156. lock can only be used on shared values at /usr/opt/perl5/lib/5.20.1/pe line 2514. END failed--call queue aborted at ./program line 8615. Unbalanced scopes: 6 more ENTERs than LEAVEs
If I start the same thing on the command line without the debugger, it just runs:
./program --debug ~/github/sbin/programconfig
I am a bit at loss how to properly debug this, as I am doing a feature extension and I am trying to hunt down an error. Any Ideas why Thread::Queue dies in the debugger but runs without the debugger? Looking at other questions regarding Thread::Queue it should be possible to debug it (although it could be hard with the threading). Also I admit, I don't quite understand the error message (the part about locking and the unbalanced scopes).

Appreciating any hints!

I got this working. For anyone who stumbles upon this: Threads need to be explicitly enabled in the debugger, even if they are not in in use. As soon as a threads module is in user, one needs to start the debugger with perl -dt program.

Replies are listed 'Best First'.
Re: Thread::Queue dies in debugger, runs without debugger
by stevieb (Canon) on Nov 01, 2017 at 13:36 UTC

    From perldebug:

    perl -dt threaded_program_name
    Debug a given program using threads (experimental).

    So essentially, instead of running with perl -d, try running with perl -dt.

    The 5.26 doc states that it's experimental, but my perldelta foo is failing this morning, so I can't figure out what version this feature was introduced. So worst case, you'll need a 5.26.x version of perl for this to work (hopefully I'll find the actual release, or someone else will).

        Holy crap, no wonder I couldn't find it. Good thing I didn't say "it's experimental, so it shouldn't have been in core for overly long" like I was going to! (I didn't, because I fully remember the whole smartmach fiasco, which iirc, is still kind of ongoing).

        Thanks for digging, pryrt!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1202503]
Approved by haukex
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2023-10-01 15:42 GMT
Find Nodes?
    Voting Booth?

    No recent polls found