Bug 150133 - Perl's eval function leaks memory when using the quoted EXPR format.
Perl's eval function leaks memory when using the quoted EXPR format.
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: perl (Show other bugs)
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Petr Rockai
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2005-03-02 15:14 EST by Jason Smith
Modified: 2007-11-30 17:07 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-06-29 02:59:40 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jason Smith 2005-03-02 15:14:22 EST
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:

while (1) {
  if (eval "$x > $t") {
    print "$x > $t = 1\n"
  } else {
    print "$x > $t = 0\n"

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

How reproducible:

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 16:26:14 EST
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 15:53:04 EDT
Is there a proposed date for fixing this? We too have been burned...
Thanks a lot,
Marilyn Safran
Comment 21 Jason Smith 2005-05-25 13:17:13 EDT
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:


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.

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

Comment 24 Warren Togami 2005-05-25 15:48:36 EDT
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 02:59:40 EDT
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 

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