RE: [perl #47467] $#- has bizarre value  Steve, Thanks for looking at this! $#- should be the last index in @- (or the last matched subgroup in the last successful match).  Clearly a number like 805468008 can't be right. In fact, trying to do something like:  @x = @-;  causes an Out of Memory error (because it's trying to allocate an array with 805468008+1 elements in it.   To answer your question, when $#+ is 0, $#- should also be 0.  And it normally is.  If you fiddle around with the program I sent by deleting the irrelevant lines, for example, you will see when you test it that it will print out  <0><0>  in almost all cases.   But for some strange reason I don't understand there are some cases where $#- has a value from some random memory location (I think) and goes bonkers. I hope that helps.  The bug is fully reproducible on my servers -- I hope you can get a reproducible test case for your test servers. -- John > -----Original Message----- > From: Steve Peters via RT [mailto:veyjhby-fbuaeanj@perl.org]  > Sent: Thursday, November 15, 2007 4:00 PM > To: Wiersba, John (TH USA) > Subject: [perl #47467] $#- has bizarre value  >  > On Wed Nov 14 16:16:30 2007, kqbk.frplfhu@thomson.com wrote: > > This is a bug report for perl from kqbk.frplfhu@thomson.com, > > generated with the help of perlbug 1.35 running under perl v5.8.7. > >   > >  > > ----------------------------------------------------------------- > > [Please enter your report here] > >   > > This bug manifests on AIX, Solaris, Cygwin.  I have not been able to > > find > > a version of this program which reproduces the bug on my  > Linux box (perl > > 5.8.5). > >   > >    #!/usr/bin/perl -w > >    use strict; > >    $| = 1; > >    my $d1 = "["; > >    my $d2 = "]"; > >    $_ = "abc xxxxx"; > >    pos = 0; > >    my @x = /abc/g; > >    print "<$#+><$#->\\n"; > >    my $x = pos $_; > >   > > produces: > >   > >    <0><41> > >   > > This bug is visible also on AIX where the output is > >   > >    <0><805468008> > >   > > There are many variations on this, sometimes producing huge  > values for > > $#-.  > > This causes perl to abort with "Out of memory" when, for example, > > copying @- > > to another array. > >   > > This bug seems to manifest in different ways depending on  > the exact code > > of > > the script.  For example, on AIX, when I remove the  > otherwise useless > > $d1 > > line, I get: > >   > >    <0><251658240> > >   > > However, when I remove the also useless $d2 line, I get: > >   > >    <0><0> > >   > > I think this shifting behavior indicates that $#- is  > getting it's value > > from > > some random area of memory which is being affected in an apparently > > random > > way depending of the state of apparently-unrelated areas of memory. > >   > > To get it to manifest on Solaris, I need to remove both the  > $d1 and $d2 > > lines: > >   > >    #!/usr/bin/perl -w > >    use strict; > >    $| = 1; > >    $_ = "abc xxxxx"; > >    pos = 0; > >    my @x = /abc/g; > >    print "<$#+><$#->\\n"; > >    my $x = pos $_; > >   > > which gives: > >   > >    <0><19529970> > >   >  > Just so we're all clear, what are you expecting the output to be? >  > Steve >