|
|
Subscribe / Log in / New account

glibc changes like this are fine

glibc changes like this are fine

Posted Oct 27, 2024 2:12 UTC (Sun) by marcH (subscriber, #57642)
Parent article: realloc() and the oversize importance of zero-size objects

> This is, it seems, a topic about which some people, at least, have strong feelings.

50+ comments here already!

> there are almost certainly programs that rely on the current behavior

Apparently just non-portable programs that have a hard dependency on glibc, so such breakage would be fine because users:
1. either use a stable / LTS GNU/Linux distribution that is not going to perform a major glibc upgrade (this change should obviously not be part of a minor release, only in a major one)
2. or they use a rolling / fast-paced / development one where everything keeps breaking anyway for a gazillion of other reasons.

To be fairer: _how_ it would break in case 2. matters. Discussed above already.


to post comments

glibc changes like this are fine

Posted Oct 27, 2024 7:08 UTC (Sun) by NYKevin (subscriber, #129325) [Link] (2 responses)

It's not that easy.

1. Stable systems eventually do need to upgrade to the next version of everything. This is already uncomfortably close to being a major flag day for those distros. Changing the behavior of something as basic as realloc would push it further in that direction.
2. There are many intermediates between an unstable distro where everything is breaking all the time and (e.g.) RHEL. Debian Testing, for example, is well known to be a reasonably well-behaved release channel in practice, and even Sid is reportedly not that bad (personally, I would never use either of those for serious purposes, but different organizations and use cases have different needs).

glibc changes like this are fine

Posted Oct 27, 2024 22:05 UTC (Sun) by NYKevin (subscriber, #129325) [Link] (1 responses)

Oh, and I forgot:

3. Hyrum's law. Most programmers do not read the C specification, they read (at most) the man page, which (on my WSL installation of Debian), says that realloc(ptr, 0) is equivalent to malloc(0) if ptr == NULL and free(ptr) otherwise (the return value section does mention that realloc(ptr, 0) may return a non-NULL pointer, but it does not distinguish between the ptr == NULL case and the ptr != NULL case, so the most straightforward interpretation is that it is talking about the former). There is no mention of portability anywhere in the document that I could find (the document claims that realloc is "conforming to" various versions of both the POSIX and C standards, without any note of this extension). Some programmers will not even go that far, they just write some code and test if it works as expected. Then the code silently picks up a glibc dependency that nobody explicitly knows about. This is not hypothetical - there is at least one comment in this thread from a developer who actually did take such a dependency and had to patch their code for musl compatibility.

In case anyone is wondering whether it is up-to-date: I honestly have no idea. It is probably outdated, because Debian, but I do not know off the top of my head how to confirm that. The colophon says it's from Linux man-pages version 5.10 and has a URL pointing to https://www.kernel.org/doc/man-pages/, which in turn tells me nothing at all about the current version of that project.

glibc changes like this are fine

Posted Oct 28, 2024 10:58 UTC (Mon) by guillemj (subscriber, #49706) [Link]

> In case anyone is wondering whether it is up-to-date: I honestly have no idea. It is probably outdated, because Debian, but I do not know off the top of my head how to confirm that. The colophon says it's from Linux man-pages version 5.10 and has a URL pointing to https://www.kernel.org/doc/man-pages/, which in turn tells me nothing at all about the current version of that project.

From the upstream link you provided you can either get to the latest version from git or from its online manuals, from the top links "bar":

https://man7.org/linux/man-pages/man3/malloc.3.html

Where there is a mention of the non-portable behavior, which I assumed would be there given that Alejandro used to maintain the manpages project until recently. The Debian version you mention is from _oldstable_, you can see where the various versions are provided for each release here for example:

https://tracker.debian.org/pkg/manpages

The version in _stable_ seems to already have the note:

https://manpages.debian.org/bookworm/manpages-dev/realloc...


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds