Prev: s/// returns the empty string, but not ""
Next: FAQ 3.21 How can I compile my Perl program into byte code or C?
From: kj on 11 Aug 2010 17:59 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. TIA! ~K
From: Ilya Zakharevich on 11 Aug 2010 18:05 On 2010-08-11, kj <no.email(a)please.post> wrote: > Bizarre copy of HASH in sassign at /usr/share/perl/5.10/Carp/Heavy.pm line 96 > 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. 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... Yours, Ilya
From: Ben Morrow on 11 Aug 2010 20:39 Quoth kj <no.email(a)please.post>: > > 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. 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. > 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"; 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. Ben
From: kj on 12 Aug 2010 13:10
Ben, Ilya: Thanks for confirming my understanding of the situation, and for the additional info on it. In <iesbj7-q28.ln1(a)osiris.mauzo.dyndns.org> Ben Morrow <ben(a)morrow.me.uk> writes: >Quoth kj <no.email(a)please.post>: >> 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.... >ITYM Test::Exception? Yes, that's what I meant. Thanks for the correction. ~K |