develooper Front page | perl.perl5.porters | Postings from March 2003

[perl #21614] 5.8.0 Unbalanced string table refcount

Thread Previous | Thread Next
From:
Paul Dyer
Date:
March 19, 2003 07:09
Subject:
[perl #21614] 5.8.0 Unbalanced string table refcount
Message ID:
rt-21614-53819.13.5786962460675@bugs6.perl.org
# New Ticket Created by  Paul Dyer 
# Please include the string:  [perl #21614]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21614 >


Hi,  

This happened on Perl 5.8.0, RedHat 8.0.  Here is a code fragment that 
produces the error listed below it:

use IO::File ();
local $/;

foreach (sort keys %altnames) { 
      my $fh = IO::File->new;
      my ($hr_title) = m/(.*)\.txt/;
      print("<hr> <h1 align=center> $hr_title </h1>\n");
      my $source = join '/', $dir, $_;
      $fh->open($source);
      while (<$fh>) { 
          print($_);
          }
      $fh->close;
      }

I have found that I get the error even for one loop. I inserted "last;" 
just after the close to test.

If I comment the print($_) statement, I still get the error.

If I comment the "while (<$fh>)" loop entirely, the errors go away!!

Here is the error log:

Unbalanced string table refcount: (1) for "Oracle.txt" during global destruction.

-------------------------------------------------------------------------------------------------------------

I was able to correct the error by using a lexical variable in the outer 
loop, thus avoiding the $_ variable at 2 levels.

my $fh = IO::File->new;

    foreach* my $file* (sort keys %altnames) { # insert each file into 
an IMG tag
      my ($hr_title) = ( $file =~ m/(.*)\.txt/ );
      print "<hr><h1 align=center> $hr_title </h1>\n";
      unless ($fh->open("$dir/$file")) {
        $r->log_error("Couldn't open $dir/$file for reading: $!");
        return SERVER_ERROR;
        }
      while (<$fh>) { # read the text files with IMG tags.
          print;
          }
      $fh->close;
      }





Thread Previous | 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