"Bizarre copy of HASH in sassign..." bug

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

Threaded View

Everyone once in a while, my code produces an error message that
looks like this:

Bizarre copy of HASH in sassign at /usr/share/perl/5.10/Carp/Heavy.pm line 96

I think it's an internal bug somewhere, and I can usually find a
way around it, but still, it's puzzling.

The latest manifestation of this problem occurred while I was
writing unit tests for a module.  My test script uses Test::More::throws_ok
to check some error conditions.  When checking this one error
condition, it generates the message copied above.  But if instead
of writing my test like this:

throws_ok { should_fail() } qr/something went awry/, "exception raised";

I write it like this:

eval { should_fail() };
ok $@ =~ qr/something went awry/, "exception raised";

everything's fine: the test passes, and the "Bizarre copy of HASH..."
error disappears.

If anyone can shed some light on this problem, I'd appreciate it.



Re: "Bizarre copy of HASH in sassign..." bug

Quoted text here. Click to load it

IIRC, this appears only when one inspects Perl stack, right?  Well,
Perl stack is not refcounted, so anything may the there.  There is no
guarantie that it contains valid values...


Re: "Bizarre copy of HASH in sassign..." bug

Quoted text here. Click to load it

Yes, it's a bug in Perl. As Ilya said, it's usually related to the fact
the Perl stack isn't refcounted (which is a bug, but not one it appears
to be possible to fix without breaking every XS extension in the world).

Some instances of it get squashed from time to time, so upgrading your
perl may be a solution. Other than that, I'm afraid you just have to
live with workarounds.

Quoted text here. Click to load it

ITYM Test::Exception? T::E uses Sub::Uplevel, which does some slightly
scary things that are more than usually likely to trigger this. Carp is
another common candidate, because they both try to examine the call
stack in ways that tend to provoke bugs.


Re: "Bizarre copy of HASH in sassign..." bug

Ben, Ilya: Thanks for confirming my understanding of the situation,
and for the additional info on it.

Quoted text here. Click to load it

Yes, that's what I meant.  Thanks for the correction.


Site Timeline