From: Andy Isaacson <adi@hexapodia.org>
To: Kurt Wall <kwall@kurtwerks.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: modutils-2.3.15 'insmod'
Date: Wed, 9 Jul 2003 11:33:56 -0500 [thread overview]
Message-ID: <20030709113356.B9732@hexapodia.org> (raw)
In-Reply-To: <20030709160823.GC267@kurtwerks.com>; from kwall@kurtwerks.com on Wed, Jul 09, 2003 at 12:08:23PM -0400
On Wed, Jul 09, 2003 at 12:08:23PM -0400, Kurt Wall wrote:
> Quoth Richard B. Johnson:
> > modutils-2.3.15, and probably later, has a bug that can prevent
> > modules from being loaded from initrd, this results in not
> > being able to mount a root file-system. The bug assumes that
> > malloc() will return a valid pointer when given an allocation
> > size of zero.
>
> This isn't a bug. The standard allow returning a non-null pointer
> for malloc(0).
It's not literally a bug in libc -- the C standard says it's
implementation-defined whether malloc(0) returns NULL or a cookie -- but
it is definitely a bug (in a portable program) to depend on either
behavior from libc. See ISO/IEC 9899:1999 7.20.3 paragraph 1.
> > The most recent `man` pages that RH 9.0 distributes states that
> > malloc() can return either NULL of a pointer that is valid for
> > free(). This, of course, depends upon the 'C' runtime library's
> > malloc() implementation.
>
> Perhaps, but IIRC, the rationale in the GNU C library was that
> existing programs assume malloc(0) != 0, which allows you to call
> realloc on the pointer. Returning NULL only makes sense if the
> malloc() call fails.
This paragraph is nonsensical, because realloc(malloc(0), 10) is
allowed, regardless of whether malloc(0) returns NULL or a cookie.
realloc(NULL, n) is allowed, and defined to be identical to malloc(n).
7.20.3.4 paragraph 3.
Geez, why does a trivial post about a bug in some program have to turn
into a pile of misleading statements and citations to ISO documents?
-andy
next prev parent reply other threads:[~2003-07-09 16:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-09 15:25 modutils-2.3.15 'insmod' Richard B. Johnson
2003-07-09 15:45 ` Andreas Schwab
2003-07-09 16:04 ` Bill Rugolsky Jr.
2003-07-09 22:44 ` H. Peter Anvin
2003-07-09 23:51 ` Richard B. Johnson
2003-07-09 16:08 ` Kurt Wall
2003-07-09 16:33 ` Andy Isaacson [this message]
2003-07-14 11:41 ` Keith Owens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030709113356.B9732@hexapodia.org \
--to=adi@hexapodia.org \
--cc=kwall@kurtwerks.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox