mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Laurent Bercot" <ska-dietlibc@skarnet.org>
To: musl@lists.openwall.com
Subject: Re[2]: [musl] Prototypes without implementations
Date: Sat, 26 Oct 2024 23:35:03 +0000	[thread overview]
Message-ID: <em5816924b-3a65-4e2d-b10a-d4a5a6aefd6e@1f92019b.com> (raw)
In-Reply-To: <ZxztEfJLtCyZ_x26@voyager>

>You call the function, and if it fails, you fall back to another method
>(which includes attempting to seed a PRNG with getauxval(AT_RANDOM) or
>trying to open /dev/urandom or the like). Does it matter if it fails
>because the kernel is too old or just having a bad day?

  That's exactly what I'm doing. That's why I have a C programming 
library
that everything I write depends on: to wrap these excuses for interfaces
into something that an application can reasonably use. It was annoying 
to
write. And the part of the library that generates random numbers was
*especially* annoying, thanks in no small part to that getrandom()
behaviour. I needed 4 attempts to make it work in a satisfying way.

  And you're saying everyone should do that, for *every* interface 
exposed
by the system? That is putting very unreasonable expectations on
application writers, and making C even harder than people like to say
it is.


>Failing with ENOSYS and no side effects and no wait time is conformant
>as well.

  Yeah. You're right. And my point, shared with other people in this
thread, is that it's a bad thing, and we should avoid having these stub
functions wherever possible.


>  (The workaround could be the self-pipe trick, which
>obviates the need for pselect() completely).

  (Using a self-pipe is also better than pselect() for other reasons:
it allows you to handle signals as regular events and process them in
normal execution context rather than interruption context. So indeed
pselect() is never needed, and the self-pipe trick - also implementable
via signalfd() on Linux - should be the regular pattern, not a
workaround.)


>If the function under test fails with
>ENOSYS, you still have no idea if that is because of a stubbed out
>implementation.

  Exactly. So let's not add to the list of functions that do that.


>If your binary links against musl, it does do precisely those tests. Not
>necessarily at the start of the runtime, but inside many functions

  It is a very deliberate, very conscious choice in musl, and the
explicit goal is that binaries linked against musl should run on as many
kernel versions as possible, independently of the kernel version musl
was built with.

  It is a reasonable design goal for a libc to avoid tying userspace to
specific kernel features. If there is ever a place to test, live, 
whether
a system call is supported, and fall back to a different system call, or
sequence of, if it isn't, a libc would be that place; and I appreciate
that musl goes to these lengths to ensure independence from the kernel.

  It is not, however, a reasonable expectation that *applications* should
do so with the system they're running on. Applications should be able
to rely on the system - that's why specifications exist. The ecosystem
is already in bad enough shape that extensive build-time configuration
(that works badly, and that nobody likes) is needed for most software;
claiming that the sensible way of writing applications is run-time tests
for system independence is abandoning any pretense of practicality.


>It is possible, though not effortless, to write sensible software using
>any of the aforementioned build systems.

  Kudos to you for making it work. Now you should know as well as I do 
that
between writing sensible software with effort, and writing half-baked
software with less effort, most of the ecosystem, including incredibly
popular projects, will choose the latter. Let's not break them even more
than they already are, please.

--
  Laurent


  parent reply	other threads:[~2024-10-26 23:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 20:01 Alyssa Ross
2024-10-25 20:10 ` Rich Felker
2024-10-25 21:38   ` Alyssa Ross
2024-10-26  1:21     ` Re[2]: " Laurent Bercot
2024-10-26  1:57       ` Thorsten Glaser
2024-10-26  2:11         ` Rich Felker
2024-10-26  8:26       ` Markus Wichmann
2024-10-26 10:28         ` Re[2]: " Laurent Bercot
2024-10-26 13:22           ` Markus Wichmann
2024-10-26 22:08             ` Thorsten Glaser
2024-10-26 23:03               ` Rich Felker
2024-10-30  9:28                 ` Alyssa Ross
2024-10-30 12:37                   ` enh
2024-10-26 23:35             ` Laurent Bercot [this message]
2024-10-27 22:43             ` Yao Zi
2024-10-26 10:10       ` Robert Clausecker

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=em5816924b-3a65-4e2d-b10a-d4a5a6aefd6e@1f92019b.com \
    --to=ska-dietlibc@skarnet.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).