Bug 114271 - 'Attempt to free unreferenced scalar' bug in perl
Summary: 'Attempt to free unreferenced scalar' bug in perl
Alias: None
Product: Fedora
Classification: Fedora
Component: perl-XML-Parser   
(Show other bugs)
Version: rawhide
Hardware: All Linux
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
Keywords: Reopened
Depends On:
TreeView+ depends on / blocked
Reported: 2004-01-25 21:13 UTC by Ed Avis
Modified: 2007-11-30 22:10 UTC (History)
1 user (show)

Fixed In Version: 5.8.8-25.fc7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-11-01 21:13:39 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
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 21:15 UTC, Ed Avis
no flags Details
Library file for test program - save in the same directory (455 bytes, text/plain)
2004-01-25 21:16 UTC, Ed Avis
no flags Details

Description Ed Avis 2004-01-25 21:13:48 UTC
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 21:15:56 UTC
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 21:16:20 UTC
Created attachment 97252 [details]
Library file for test program - save in the same directory

Comment 3 Warren Togami 2005-09-04 10:14:46 UTC
Has this been reported to upstream CPAN?  Has this been fixed upstream?

Comment 4 Ed Avis 2005-09-04 15:30:25 UTC
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 11:19:18 UTC
I mean, is this an issue with a non-Fedora build of perl? 

Comment 6 Ed Avis 2005-09-05 13:27:14 UTC
OK, I'll download a vanilla source tarball of perl5 and see if I can reproduce

Comment 8 Ed Avis 2007-10-18 12:03:41 UTC
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 17:19:59 UTC
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 12:15:11 UTC
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 13:23:45 UTC

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 12:43:26 UTC
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;

Comment 13 Ed Avis 2007-10-25 13:07:56 UTC
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 21:13:38 UTC
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.