"Attempt to free unreferenced scalar" when running a perl program

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.4
  • perl-5.8.8-28.el5

Issue

  • 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.

Resolution

  • Update to perl version 5.8.8-32.el5.2 or later to fix this issue

Root Cause

  • This is due to a bug in perl, which has been fixed in the following errata:
    • http://rhn.redhat.com/errata/RHBA-2010-0712.html

Diagnostic Steps

  • Execute the following perl script:
 #!/usr/bin/perl  

 use threads;  

 my $subref = sub { 42; };  

 my $t;  

 while(1) {  
 $t=threads->new($subref);  
 $t->join();  
 }
  • Execution of the program results in the following output:
 $ perl test2.pl  
 Attempt to free unreferenced scalar: SV 0x7b5a840, Perl interpreter: 0x7a1e2f0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7cf60, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7cf60, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7d270, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7d7b0, Perl interpreter: 0x7b4cfb0 during global destruction.  
 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.  
 Attempt to free unreferenced scalar: SV 0x7b7e700, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7ec30, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7f0a0, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7f5e0, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b7fad0, Perl interpreter: 0x7b4cfb0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b80010, Perl interpreter: 0x7a1e2f0 during global destruction.  
 Attempt to free unreferenced scalar: SV 0x7b80510, Perl interpreter: 0x7b25f60 during global destruction.  
 .  
 .

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.