Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Stupid question

by runrig (Abbot)
on May 19, 2011 at 16:29 UTC ( #905745=note: print w/ replies, xml ) Need Help??


in reply to (tye)Re: Stupid question
in thread Stupid question

Posted only to maybe help someone else at some point in time...

Update: It's all about this Carp bug (w/this solution) and modifying global variables ( @ARGV in this case - GetOptions modifies @ARGV ) after they get passed to functions.

Although I agree with this format (but have mostly not gotten in the habit of using it myself), one of my co-workers was doing something similar, and got the following error during a Carp::confess from deep within the code (perl 5.8.8 - and we could not come up with a simple test case):

Bizarre copy of HASH in sassign at ...../Carp/Heavy.pm line 45

Although it seemed to be a completely unrelated part of the code, moving the Getopt::Long::GetOptions() call from inside to outside of Main() fixed the problem, and we got the proper confess with stack trace that we wanted to see. Though I'm sure when something with this much deep magic goes wrong, we've probably only fixed a symptom of the problem :-)


Comment on Re^2: Stupid question
Download Code
Re^3: Stupid question (heisenbugs)
by tye (Cardinal) on May 19, 2011 at 16:47 UTC

    Yes, those kind of errors are where any random change can prevent / postpone the error. For example, running under the Perl debugger is frequently one way to make the error go away. This can be a convenient way to get the stack trace and it can be very inconvenient in preventing you from being able to use the debugger to get more information. I've also often seen turning up trace or adding "debug prints" make such bugs no longer reproduce.

    But such voodoo changes usually just postpone the problem for a while.

    I'm glad you got the call stack and were able to use that to debug the problem that was causing Carp to be called. But if I were in your shoes, then I would be worried of other things eventually causing more "bizarre copy" panics.

    In such cases, I usually look for a minor Perl upgrade, upgrades for XS-using modules, or elimination of the use of some XS-using modules.

    Also, these bugs are much more likely in an environment like a Perl daemon or like mod_perl where you have an interpreter instance that runs for quite a long time doing tons of things. Re-spawning the daemon periodically or configuring mod_perl to restart children a bit more often can reduce the frequency of such bugs appearing.

    - tye        

      The "bizarre copy" errors from Carp so far seem to only happen when one particular module wants to throw an error (unless I do something like this on purpose). When I apply this eval band aid, Carp reports the real error instead of the useless error that may never be fixed. The error has something to do with lack of ref counting of the stack. It would be nice if Carp were patched as in the RT ticket, as it restores Carp to being at least somewhat useful when this happens.
        The error has something to do with lack of ref counting of the stack.

        Well, that is asserted in https://rt.perl.org/rt3/Public/Bug/Display.html?id=77706 but no justification or even discussion of that assertion is apparent or even linked from it and I find the assertion not credible. Items on the stack in Perl are still ref-counted, just somewhat differently. There may be a fundamental flaw in this difference but I have not heard it described and it is not apparent to me.

        If you run into some actual discussion or even a description that is not ridiculously vague, please point such out.

        - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://905745]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-11-27 18:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (187 votes), past polls