Bug 114271 - 'Attempt to free unreferenced scalar' bug in perl
'Attempt to free unreferenced scalar' bug in perl
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: perl-XML-Parser (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tom "spot" Callaway
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-01-25 16:13 EST by Ed Avis
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version: 5.8.8-25.fc7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-11-01 17:13:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Perl program to print 'Attempt to free unreferenced scalar' message - but needs test_library too (198 bytes, text/plain)
2004-01-25 16:15 EST, Ed Avis
no flags Details
Library file for test program - save in the same directory (455 bytes, text/plain)
2004-01-25 16:16 EST, Ed Avis
no flags Details

  None (edit)
Description Ed Avis 2004-01-25 16:13:48 EST
This is a bug in perl or in the XML::Parser module which I have been tracking down.  Please try the example code included in the report and see if you can reproduce the bug.  If you are unable to reproduce it, I will try to narrow down the test case further still.  The bug is a message

Attempt to free unreferenced scalar: SV 0x8063b9c during global destruction.

which indicates some screwup in perl's data structures.  While investigating the bug I also saw 'Attempt to free temp prematurely' appearing as well, but the minimal test case produces just one error message.

Please save the first attached file as 'test_program' and the second as 'test_library'.  The split into two separate files is necessary to reproduce the bug, at least for me.  Then run

% perl ./test_program

to see the 'unreferenced scalar' message, along with a correct message about main::foo.

(I have manually upgraded some perl packages from the Fedora development SRPMs or from CPAN while investigating this bug, but I hope you will be able to see it on your installation too.)
Comment 1 Ed Avis 2004-01-25 16:15:56 EST
Created attachment 97251 [details]
Perl program to print 'Attempt to free unreferenced scalar' message - but needs test_library too
Comment 2 Ed Avis 2004-01-25 16:16:20 EST
Created attachment 97252 [details]
Library file for test program - save in the same directory
Comment 3 Warren Togami 2005-09-04 06:14:46 EDT
Has this been reported to upstream CPAN?  Has this been fixed upstream?
 
Comment 4 Ed Avis 2005-09-04 11:30:25 EDT
No, I reported it here first because Red Hat applies some patches to the vanilla
perl distribution.  FWIW, I can still reproduce this on FC4 with perl-5.8.6-15
and perl-XML-Parser-2.34-6.
Comment 5 Warren Togami 2005-09-05 07:19:18 EDT
I mean, is this an issue with a non-Fedora build of perl? 
Comment 6 Ed Avis 2005-09-05 09:27:14 EDT
OK, I'll download a vanilla source tarball of perl5 and see if I can reproduce
there.
Comment 8 Ed Avis 2007-10-18 08:03:41 EDT
I can confirm that this bug is reproducible with non-Fedora perl5.

It is also reproducible with Fedora 6.  The error message is now

Attempt to free unreferenced scalar: SV 0x9953804, Perl interpreter: 0x9952008
during global destruction.

Again, this indicates some memory management bug inside perl itself.  Are you
able to reproduce it?
Comment 9 Tom "spot" Callaway 2007-10-18 13:19:59 EDT
Wow, what an old bug! I was able to find a fix for this one though, I'm about to
commit it to rawhide.
Comment 10 Ed Avis 2007-10-22 08:15:11 EDT
Hooray - I'm glad you were able to squash this one.  If you point me to the SRPM
for the fixed source package in rawhide I will be able to test and confirm the fix.

Sorry for taking two years to test whether vanilla (non-Fedora) perl5 also has
the bug.
Comment 11 Tom "spot" Callaway 2007-10-22 09:23:45 EDT
http://koji.fedoraproject.org/koji/buildinfo?buildID=21594

perl-5.8.8-30 has the fix. Once you confirm that it works for more complicated
cases than your testcase (I already confirmed that it resolves that), I'll push
the fix out as an update for FC-6/F-7.
Comment 12 Ed Avis 2007-10-25 08:43:26 EDT
FTR, Joris van Rantwijk in Debian bug 230844
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=230844> discovered that
XML::Parser is not guilty.  You can still reproduce the bug using test_program
attached above and the following code for test_library:

package Fred;
sub new {
    my ($class, %args) = @_;
    my $handlers = $args{Key};
    bless $handlers;
}
sub parse {
  my ($self, $s) = @_;
  $self->{'/a'}->($self, 'Fred::Foo'->bar($self));
}
package Fred::Foo;
sub bar {
    my $class= shift;
}
sub children {
    my $elt= shift;
}
1;
Comment 13 Ed Avis 2007-10-25 09:07:56 EDT
I confirm that the new perl package fixes the test program and also Joris van
Rantwijk's simplified test program.  I no longer remember exactly what triggered
the bug in the first place but I suspect it was some use of XML::DOM.  Thanks.
Comment 14 Fedora Update System 2007-11-01 17:13:38 EDT
perl-5.8.8-25.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.