Bug 461481 - [5.2] valloc() fails with ENOMEM without trying to use arenas
[5.2] valloc() fails with ENOMEM without trying to use arenas
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: glibc (Show other bugs)
5.2
All Linux
urgent Severity urgent
: rc
: ---
Assigned To: Jakub Jelinek
Brian Brock
: ZStream
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-08 09:46 EDT by Flavio Leitner
Modified: 2016-11-24 11:14 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-01-20 15:49:38 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
proposed patch to fix valloc() to fall back to arena. (1.98 KB, patch)
2008-09-08 09:51 EDT, Flavio Leitner
no flags Details | Diff
patch fixing valloc/pvalloc to fall back to arenas (3.13 KB, patch)
2008-09-12 08:37 EDT, Flavio Leitner
no flags Details | Diff
backport for 2.5-25 (3.11 KB, patch)
2008-09-12 15:33 EDT, Flavio Leitner
no flags Details | Diff
backport for 2.5-24 [RHEL-5.2] (3.11 KB, patch)
2008-09-12 16:15 EDT, Flavio Leitner
no flags Details | Diff

  None (edit)
Description Flavio Leitner 2008-09-08 09:46:46 EDT
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 Product and Program Management 2008-09-08 09:49:44 EDT
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 09:51:20 EDT
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 08:37:40 EDT
Created attachment 316566 [details]
patch fixing valloc/pvalloc to fall back to arenas
Comment 8 Flavio Leitner 2008-09-12 15:33:52 EDT
Created attachment 316613 [details]
backport for 2.5-25
Comment 9 Flavio Leitner 2008-09-12 16:15:40 EDT
Created attachment 316623 [details]
backport for 2.5-24 [RHEL-5.2]
Comment 18 errata-xmlrpc 2009-01-20 15:49:38 EST
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

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