Bug 150133

Summary: Perl's eval function leaks memory when using the quoted EXPR format.
Product: Red Hat Enterprise Linux 3 Reporter: Jason Smith <smithj4>
Component: perlAssignee: Petr Rockai <prockai>
Status: CLOSED WONTFIX QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 3.0CC: marilyn.safran, tao, wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-06-29 06:59:40 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:

Description Jason Smith 2005-03-02 20:14:22 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.3)
Gecko/20050104 Red Hat/1.4.3-3.0.7

Description of problem:
I have a long running daemon process written in perl that makes heavy
use of perl's eval function.  I noticed a memory leak and after some
debugging have narrowed the leak down to the eval statement.  Here is
a simple test script which exhibits the same memory leak:

#!/usr/bin/perl
$t=10;
while (1) {
  $x=int(rand(20));
  if (eval "$x > $t") {
    print "$x > $t = 1\n"
  } else {
    print "$x > $t = 0\n"
  }
}


Version-Release number of selected component (if applicable):
perl-5.8.0-89.10

How reproducible:
Always

Steps to Reproduce:
1. run test script.
2. repeatedly look at the process memory usage using ps and watch it grow.
3. kill the script before the system runs out of memory.
    

Actual Results:  Process leaks memory.

Expected Results:  Process should not leak memory.

Additional info:

I have tested the same script on other systems (AIX, Solaris &
debian), which have different versions of perl installed and none of
them leak memory.  Using the second form of eval with the {BLOCK},
which is parsed only once, does not leak memory.

Comment 1 Jason Smith 2005-03-02 21:26:14 UTC
I should also add that I cannot use the once-parsed {BLOCK} format of
eval since my code actually has a test expression which changes in a
variable like this:

$t='> 10';

with an eval statement like:

if (eval "$x $t") ....


Comment 18 Marilyn Safran 2005-05-24 19:53:04 UTC
Is there a proposed date for fixing this? We too have been burned...
Thanks a lot,
Marilyn Safran
marilyn.safran.il

Comment 21 Jason Smith 2005-05-25 17:17:13 UTC
We also have a support ticket open for this problem (issue #68865).  There
RedHat has verified that the leak exists on perl 5.8.0 only.  I think it was
fixed in perl 5.8.1 and above, but the exact cause and fix is difficult to
extract from the major changes that went into core perl with respect to eval:

http://www.mail-archive.com/perl5-changes@perl.org/msg05868.html

I believe right now RH is thinking of building a new perl package based on a
newer upstream version of perl for us to test.  I assume that if this fixes the
problem and doesn't break anything else then it might go into a future RHEL3
update, maybe U6 or later....

Another possible option is to upgrade to RHEL4 which comes with perl-5.8.5,
since it doesn't suffer from this eval memory leak.

~Jason


Comment 22 Marilyn Safran 2005-05-25 18:55:26 UTC
Thanks for the info.

Marilyn

Comment 24 Warren Togami 2005-05-25 19:48:36 UTC
A possible perl update package would probably be 5.8.5, because 5.8.1 is known
to break ABI, and it would be less of a maintenance burden in the long term to
make it match RHEL4's 5.8.5.  Every perl version in 5.8.x is supposed to be ABI
compatible (5.8.1 screwed up), so modules built on 5.8.0 *theoretically* will
work on 5.8.5.  There are however several other contributing factors (like gcc
or other libraries) that might complicate things.

Comment 32 Petr Rockai 2005-06-29 06:59:40 UTC
Ok as for this bug, it is not going to be fixed. The possible fix is too   
complicated for an update release and there is still a possibility to upgrade   
to rhel4 or upgrade perl only (the latter is however completely unsupported by   
redhat). The bug only affects limited number of systems so those should be   
dealt with on a case-by-case basis. There is an UNOFFICIAL backport from rhel4  
at http://people.redhat.com/prockai/perl-rhel3-backport/ -- it is there to help  
you if you need rhel3 with a fixed perl release, but i should reiterate that it  
is completely UNSUPPORTED. The preferred solution, if possible, would be to  
upgrade to rhel4. I am sorry about this, but it is about as much as can be 
done.