Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 537777

Summary: 'Attempt to free unreferenced scalar' when running a perl program with threads
Product: Red Hat Enterprise Linux 5 Reporter: Issue Tracker <tao>
Component: perlAssignee: perl-maint-list
Status: CLOSED ERRATA QA Contact: Petr Šplíchal <psplicha>
Severity: high Docs Contact:
Priority: high    
Version: 5.4CC: jpazdziora, mpoole, ohudlick, ppisar, psplicha, rvokal, tao
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: perl-5.8.8-28.el5 Doc Type: Bug Fix
Doc Text:
Cause Joining or undefining a thread variable (using undef) in a perl program results in an internal perl error. Consequence Error message on stderr: Attempt to free unreferenced scalar: SV 0x7b5a840, Perl interpreter: 0x7a1e2f0 during global destruction. Fix Backport of upstream patch fixed perl internals. Result The internal error do not show up.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-21 05:39:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 629935    
Attachments:
Description Flags
backport of upstream patch none

Description Issue Tracker 2009-11-16 10:46:27 UTC
Escalated to Bugzilla from IssueTracker

Comment 1 Issue Tracker 2009-11-16 10:46:30 UTC
Event posted on 2009-11-14 07:29 GMT by spoyarek

Base OS: RHEL-5.4

Problem Description:

Joining or undefining a thread variable (using undef) in a perl program results in an internal perl error:
Attempt to free unreferenced scalar: SV 0x7b5a840, Perl interpreter: 0x7a1e2f0 during global destruction.

How Reproducible:

Always

Steps to Reproduce:

$ cat test.pl
#!/usr/bin/perl

use threads;

my $subref = sub { 42; };

my $t;

while(1) {
    $t=threads->new($subref);
    $t->join();
}

$ perl test2.pl

Actual Result:

Attempt to free unreferenced scalar: SV 0x7b7dcb0, Perl interpreter: 0x7b4cfb0 during global destruction.
Attempt to free unreferenced scalar: SV 0x7b7e1e0, Perl interpreter: 0x7b4cfb0 during global destruction.
.
.

Expected Result:

The internal error should not show up.
 
Additional Information:

An upstream patch is available, which fixes this:

http://perl5.git.perl.org/perl.git/commitdiff/dd5ef8e06fad97042101d2f0784676bb2111654b

I have attached a patch adapted to RHEL-5. I have tested it to verify that it works. Would like a review of the patch so that I can give a test package to the customer to verify.
This event sent from IssueTracker by mpoole  [Support Engineering Group]
 issue 365873

Comment 2 Martin Poole 2009-11-16 10:47:59 UTC
Created attachment 369666 [details]
backport of upstream patch

Comment 3 Martin Poole 2009-11-16 10:52:22 UTC
Reproducer can be reduced to

#!/usr/bin/perl

use threads;

my $subref = sub { 42; };

my $t=threads->new($subref);
$t->join();

Comment 4 Marcela Mašláňová 2009-11-16 12:20:13 UTC
The patch looks all right.

Comment 7 RHEL Program Management 2010-08-09 18:55:39 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 18 Marcela Mašláňová 2011-09-26 07:23:39 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
    Joining or undefining a thread variable (using undef) in a perl program results in an internal perl error.
Consequence
    Error message on stderr: Attempt to free unreferenced scalar: SV 0x7b5a840, Perl interpreter: 0x7a1e2f0
during global destruction.
Fix
    Backport of upstream patch fixed perl internals.
Result
    The internal error do not show up.

Comment 20 errata-xmlrpc 2012-02-21 05:39:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0199.html