develooper Front page | perl.perl5.porters | Postings from September 2008

Non-deterministic behaviour with simple array initialization

Thread Next
From:
Thomas Karcher
Date:
September 24, 2008 00:12
Subject:
Non-deterministic behaviour with simple array initialization
Message ID:
1222240363.5411.11.camel@localhost
Hi there,

I'm running perl 5.10.0 on a SuSE 10.3 Xen guest with up-to-date CPAN
modules and I am observing a rather strange array behaviour with the
following program:

====
my $i = 0;
while (1) {
        my @e;

        for  my $j (0..@e / 2 - 1) {
                die "died where I shouldn't have: $i";
        }
        $i++;
}
====

Since @e is empty when the for statement is evaluated, the "die" should
never be called. Instead, it is called sooner or later. Some examples:

main:~ # perl for.pl 
Illegal division by zero at for.pl line 9.
main:~ # perl for.pl 
died where I shouldn't have: 16286662 at for.pl line 10.
main:~ # perl for.pl 
died where I shouldn't have: 28768303 at for.pl line 10.
main:~ # perl for.pl 
died where I shouldn't have: 56541046 at for.pl line 10.

... which means that at some point suddenly @e is not undef anymore.

There is a second Xen VM with roughly the same installation, but there
is no such behaviour.

Any ideas how I could debug this further? Or do you recognize this as a
known bug that I didn't find?


Thanks!

Thomas



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About