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 461481

Summary: [5.2] valloc() fails with ENOMEM without trying to use arenas
Product: Red Hat Enterprise Linux 5 Reporter: Flavio Leitner <fleitner>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Brian Brock <bbrock>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.2CC: fweimer, pmuller, sputhenp, tao
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-01-20 20:49:38 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:
Attachments:
Description Flags
proposed patch to fix valloc() to fall back to arena.
none
patch fixing valloc/pvalloc to fall back to arenas
none
backport for 2.5-25
none
backport for 2.5-24 [RHEL-5.2] none

Description Flavio Leitner 2008-09-08 13:46:46 UTC
Description of problem:

When each thread of a multi-threaded process calls valloc()
individually, valloc() sometimes fails with ENOMEM even if the virtual
memory of the process is available enough.

Version-Release number of selected component:

 Red Hat Enterprise Linux Version Number: 5
 Release Number: 2
 Architecture: ia64
 Kernel Version: 2.6.18-92.el5
 Related Package Version: glibc-2.5-24
 Related Middleware / Application: None

How reproducible:
Always.

Step to Reproduce:
Execute our reproducer as follows.

1) Extract our tar ball.
$ tar zxf mvalloc-race.tar.gz

2) Compile the reproducer.
$ cd mvalloc
$ make

3) Execute a reproducer.
$ ./mvalloc-race-v7

Actual Results:
valloc() fails with ENOMEM even if the virtual memory is
available enough.

The output of the reproducer is as follows.

localhost% ./mvalloc-race-v7
valloc(4063232) failed, err:12
zsh: 31196 abort (core dumped)  ./mvalloc-race-v7

Hardware configuration:

 Model: PRIMEQUEST 580
 CPU Info: Itanium 2(1.6GHz) x4
 Memory Info: 4GB
 Hardware Component Information: None
 Configuration Info: None
 Guest Configuration Info: None


It was tried memalign() instead of valloc() in the reproducer because
specification difference between valloc() and memalign() is not so much, 
but this problem does -not- occurred.

The implementation difference between valloc() and memalign() is its
action when _int_memalign() returns NULL. I think this difference
causes this problem. The detail of the action is as follows.

The memalign() checks the return value of _int_memalign(). If
_int_memalign() returns NULL, memalign() tries to get memory from the
main_arena. However, valloc() does not check the return value of
_int_valloc() that is the return value of _int_memalign().
_int_valloc() calls _int_memalign() internally. I think this is the
reason why valloc() fails with ENOMEM, and why memalign() does not fail.

Comment 1 RHEL Program Management 2008-09-08 13:49:44 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 2 Flavio Leitner 2008-09-08 13:51:20 UTC
Created attachment 316081 [details]
proposed patch to fix valloc() to fall back to arena.

I'm attaching a patch fixing valloc() to use arenas areas like memalign() does.

Flavio

Comment 6 Flavio Leitner 2008-09-12 12:37:40 UTC
Created attachment 316566 [details]
patch fixing valloc/pvalloc to fall back to arenas

Comment 8 Flavio Leitner 2008-09-12 19:33:52 UTC
Created attachment 316613 [details]
backport for 2.5-25

Comment 9 Flavio Leitner 2008-09-12 20:15:40 UTC
Created attachment 316623 [details]
backport for 2.5-24 [RHEL-5.2]

Comment 18 errata-xmlrpc 2009-01-20 20:49:38 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-0080.html