Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bizarre copy of HASH in list assignment...

313 views
Skip to first unread message

Manfred Lotz

unread,
Mar 31, 2015, 4:45:07 AM3/31/15
to begi...@perl.org
Hi there,
I have a script where I use croak and somebody else using that script
gets

Bizarre copy of HASH in list assignment
at /usr/share/perl/5.20/Carp.pm line 228.

I get a message like this, instead:

Variable b has empty value! at ./x.pl line 23.
main::myfunc() called at ./x.pl line 8

which is what should happen.

Any idea what this message means? I'm not able to reproduce it.

Here a minimal example:

#! /usr/bin/perl

use strict;
use warnings;

use Carp;

myfunc();



sub myfunc {
my %vars = (
'a' => 'some val',
'b' => q{},
);

while ( my ( $key, $val ) = each %vars ) {
if ( not defined $val ) {
croak "No value given for $key";
}
if ( $val eq q{} ) {
croak "Variable $key has empty value!";
}
}
return;
}


--
Manfred

Shlomi Fish

unread,
Mar 31, 2015, 6:30:11 AM3/31/15
to begi...@perl.org, Manfred Lotz
Hi Manfred,
This code looks fine to me (except for some \t|4-space-indent mixup, which is
relatively minor). I cannot reproduce the reported problem here
( perl-5.20.1-8.mga5 on Mageia Linux x86-64 5 - I'm getting something similar
to what you are getting).

Can you please ask your friend for:

1. Operating system + version.

2. The perl 5 distribution and its version.

3. Version of Carp.pm and the surrounding lines.

4. Other parameters of their environment.

Maybe this way we'll be able to reproduce it.

Regards,

Shlomi Fish

--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
http://www.shlomifish.org/humour/bits/facts/Summer-Glau/

95% of Programmers consider 95% of the code they did not write, in the bottom
5%.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Andy Bach

unread,
Mar 31, 2015, 12:30:06 PM3/31/15
to Manfred Lotz, Perl Beginners

On Tue, Mar 31, 2015 at 3:28 AM, Manfred Lotz <manfre...@arcor.de> wrote:

Bizarre copy of HASH in list assignment
at /usr/share/perl/5.20/Carp.pm line 228.

which suggests:

A "Bizarre copy" occurs when Perl's stack is corrupted or contains non-scalars. It occurs as the result of bugs in Perl itself or in XS modules. (Brian Gerard's example exercises one of a long list of known bugs related to the stack not being ref-counted.)

You could isolate the problem by adding the following to the anon sub:

...


Manfred Lotz

unread,
Apr 12, 2015, 6:45:04 AM4/12/15
to begi...@perl.org
Hi Shlomi,
it took me a while to get back to it.

The versions of the two systems where the error came up are:

1.
Slackware 14.0, kernel 3.2.29-smp
"This is perl 5, version 16, subversion 3 (v5.16.3) built for
i486-linux-thread-multi" Carp.pm:
our $VERSION = '1.26';

2.
Debian testing ("Debian 3.16.7-ckt7-1 (2015-03-01) i686")
This is perl 5, version 20, subversion 2 (v5.20.2) built for
i586-linux-gnu-thread-multi-64int

Carp.pm:
our $VERSION = '1.3301';


From what Andy said I think it is not easy to reproduce the error. I
was not successful when trying it out on my system with the same Perl
(perhaps a different patch level, though), and the same data. At least,
I'm sure it is not reproducible using a minimal example.


I don't know if this setting has any influence:

main( @ARGV ) unless caller();

sub main {
...
}

sub ...


I just worked around by using warn/die again.


--
Manfred
0 new messages