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

[perl #21614] 5.8.0 Unbalanced string table refcount

Thread Previous | Thread Next
Paul Dyer
March 19, 2003 07:09
[perl #21614] 5.8.0 Unbalanced string table refcount
Message ID:
# New Ticket Created by  Paul Dyer 
# Please include the string:  [perl #21614]
# in the subject line of all future correspondence about this issue. 
# <URL: >


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, $_;
      while (<$fh>) { 

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.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About