Bug 1063330

Summary: memory leak when including a file with "use utf8"
Product: Red Hat Enterprise Linux 7 Reporter: Petr Pisar <ppisar>
Component: perlAssignee: perl-maint-list
Status: CLOSED ERRATA QA Contact: Martin Kyral <mkyral>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.0CC: isenfeld, jorton, jplesnik, mkyral
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: x86_64   
OS: Linux   
URL: https://rt.perl.org/Public/Bug/Display.html?id=121200
Whiteboard:
Fixed In Version: perl-5.16.3-288.el7 Doc Type: Bug Fix
Doc Text:
Cause: Including file with "use utf8" Consequence: When perl includes a file with "use utf8" and text constants it leaks memory. Fix: Upstream fix that the temp utf8 copy of namepv is correctly freeing. Result: Including "use utf8" and constant does not leak.
Story Points: ---
Clone Of: 1062576 Environment:
Last Closed: 2016-11-04 00:15:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Upstream fix applicable to 5.16.3 none

Description Petr Pisar 2014-02-10 14:11:58 UTC
+++ This bug was initially created as a clone of Bug #1062576 +++

Description of problem:
Every time perl includes a file with "use utf8" and text constants it leaks memory.


Version-Release number of selected component (if applicable):
perl-5.16.3-266.fc19.x86_64

How reproducible:
always

Steps to Reproduce:
1. run the test program below
2. watch as memory usage grows

Here is the test program:
-------------------------
my $mem = 0;
sub report_memory () {
        my $next_mem = qx[ps -p $$ -o size=]+0;
        printf "%+8d = %8d K\n", $next_mem-$mem, $next_mem; $mem = $next_mem;
}

for (0..1e5) {
        do 'x.inc';
        report_memory unless $_ % 1e4;
}
-------------------------

x.inc contains:
-------------------------
use utf8;
$x='x';
-------------------------

--- Additional comment from Petr Pisar on 2014-02-10 13:49:09 GMT ---

Upstream report <https://rt.perl.org/Public/Bug/Display.html?id=121200>.

--- Additional comment from Petr Pisar on 2014-02-10 14:09:35 GMT ---

All Fedoras are affected (confirmed on perl-5.18.2-296.fc21.x86_64, perl-5.18.2-289.fc20.x86_64, perl-5.16.3-266.fc19.x86_64).
------

RHEL-7 is affected (perl-5.16.3-283.el7.x86_64).

Comment 3 Petr Pisar 2015-10-27 16:03:05 UTC
Created attachment 1086911 [details]
Upstream fix applicable to 5.16.3

Comment 7 Jitka Plesnikova 2016-03-03 14:50:17 UTC
How reproduce:

1) Install perl

2) Create test data file 
x.inc contains:
-------------------------
use utf8;
$x='x';
-------------------------

3) Create the test program:
-------------------------
my $mem = 0;
sub report_memory () {
        my $next_mem = qx[ps -p $$ -o size=]+0;
        printf "%+8d = %8d K\n", $next_mem-$mem, $next_mem; $mem = $next_mem;
}

for (0..1e5) {
        do 'x.inc';
        report_memory unless $_ % 1e4;
}
-------------------------

4) Run the test and watch the memory usage

Comment 10 errata-xmlrpc 2016-11-04 00:15:38 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.

https://rhn.redhat.com/errata/RHBA-2016-2191.html