Bug 86420 - malloc on bigmem SMP kernel returns EINVAL
malloc on bigmem SMP kernel returns EINVAL
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2003-03-21 14:05 EST by Bob Nataly
Modified: 2007-04-18 12:52 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-10-03 15:56:00 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 Bob Nataly 2003-03-21 14:05:56 EST
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 16:00:29 EST
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 
Comment 2 Jakub Jelinek 2003-03-21 16:07:57 EST
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.

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