debugging Carp

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


Debugging some problems I had (with map), I got extra errors under the
debugger, while trying to step around calls to warn:

Bizarre copy of ARRAY in sassign at /usr/lib/perl5/5.10/Carp/
line 104, <GEN1> line 1.

104:      my $arg = shift;
  DB<10> x @_
Bizarre copy of ARRAY in leaveeval at /usr/lib/perl5/5.10/
line 638, <GEN1> line 1.

The first occurrence was still under my using 'map'.
I see that Carp itself uses a DB package.
Can there be that it conflicts with the debugger?

The second occurrence happened after I had switched my using map for
grep, and got the expected behaviour without the debugger.

I couldn't narrow the problem down yet.


Re: debugging Carp

Quoted text here. Click to load it

This is a bug in perl, or in the debugger. I'm not terribly surprised:
@_ is deeply weird (especially when you've 'shift'ed it), and the
debugger is deeply weird; mix the two and presto! you get bugs :(. (Carp
uses some of the debugger hooks internally, so it's not surprising it
hits some of the same bugs.)

If you need a solution you could try upgrading to 5.12.1, to see if it's
been fixed; you could also try searching /
for a known bug. It may be worth reporting a new bug if you don't find
one that matches, especially if you've got a really simple testcase. looks like your
Carp error; it is unfixed, and appears to fall into the general category
of 'perl's stack isn't refcounted' bugs, which are unfortunately more
common that they should be and extremely difficult to fix (without
breaking half the XS in existence).


Re: debugging Carp

Quoted text here. Click to load it

A google P5P thread cites this example below.
Pending a fix, a workaround should be possible
in some cases:

use diagnostics;
my @x = 1 .. 10;
sub s1 {
   @x = ();  # don't do this now!
   my $x = qr/a/;
   for (@_) {
sub s2 {
   my $y = shift;  # error here
   print $y;


(P) Perl detected an attempt to copy an internal value that
  is not copyable.
Bizarre copy of ARRAY in sassign ...

Charles DeRykus

Re: debugging Carp

Quoted text here. Click to load it

Thanks to both of you.
I don't need a fix: it is enough for me to have some reason to trust
my own code (who said I have few?).

And I couldn't narrow my problem into a neat case.


Site Timeline