Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 86420

Summary: malloc on bigmem SMP kernel returns EINVAL
Product: [Retired] Red Hat Linux Reporter: Bob Nataly <bnataly>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-03 19:56:00 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 Bob Nataly 2003-03-21 19:05:56 UTC
Description of problem:

On [Linux 2.4.20-2.48bigmem #1 SMP Thu Feb 13 11:31:10 EST 2003 i686
i686 i386 GNU/Linux] in a threaded application, when calling malloc, sometimes 
errno is set to EINVAL.  The malloc function does seem to return a valid 
pointer, as apposed to NULL which is supposed to be returned on an actual error.

According to the man page, error codes of only 0 or ENOMEM are expected.  The 
man pages on other platforms suggest that EINVAL may be set if malloc(0) is 
called.  We are not calling malloc with an argument of 0.


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

gcc version 3.2.1 20030202 (Red Hat Linux 8.0 3.2.1-7)

Comment 1 Bob Nataly 2003-03-21 21:00:29 UTC
Setting the environment variable MALLOC_CHECK_ = 1 or 2 eliminates this 
problem.  I don't know why, as MALLOC_CHECK_ is only supposed to be a debugging 
aid and is not supposed to effect the behavior of the actual malloc function 
call.  However, obviously it does, as malloc is no longer setting errno to 
EINVAL.


Comment 2 Jakub Jelinek 2003-03-21 21:07:57 UTC
You mean that malloc returns non-NULL and sets errno to EINVAL?
That is completely legal. With the exception of a few routines named in the
standards (I remember ATM only some math functions, there are a few others
I think), errno has defined value only after function fails (typically
returns -1, in the case of malloc NULL).
So, unless malloc returns NULL, you shouldn't look what value errno has,
it can have any.