HNHacker News
TopNewBestAskShowJobs

dalias

162 karma · joined June 2, 2012

submissionscomments
dalias··on Musl-libc version 1.0.0 released
A special treat to go with the release, that's not linked on the website yet: in-browser demo setup using jslinux: http://www.musl-libc.org/jslinux/
dalias··on Comparison of C/Posix standard library implementations for Linux
Yes. If anyone has suggestions for other comparison points I should add that would be more balanced, I can try to add them (but some things require non-trivial work to measure so it might take me a while to get around to it). Note that the comparison table as it stands it pretty old, but very little has changed since I did it except musl getting slightly bigger and glibc getting a lot bigger (and eglibc merging back into glibc, so it's rather pointless to talk about it as "eglibc" anymore). :-)
dalias··on Comparison of C/Posix standard library implementations for Linux
The size isn't really an issue for most desktop or server oriented distributions. Perhaps bigger issues for distros are:

- Symbol versioning: If you have a newer glibc installed when you build your packages, they'll refuse to run on older glibc, even if they don't need any of the new version's features. This makes it hard to make packages that support multiple versions of a distribution (e.g. a stable release with an older glibc and an unstable release with a newer one).

- Awkwardness of upgrading: For example Debian usually wants you to restart X and any daemons that use nss when glibc is updated. There are also atomicity issues during upgrade where there's a race window during which execing programs can fail.

On the other hand, distros are invested in a huge set of packages as well as support for third-party (often non-free) software, all of which are presently linked with glibc. I think musl is a lot more interesting right now to new and upcoming distros that are looking for a fresh start with less baggage than as a migration path for the big distros with major user/customer bases, at least in the short term. In the long term, who knows what will happen... :-)

dalias··on Comparison of C/Posix standard library implementations for Linux
The musl figures may be somewhat outdated since musl is developing rather quickly. With regards to the others, the main thing that's outdated is the size of glibc. It's considerably larger now. :-)
dalias··on Comparison of C/Posix standard library implementations for Linux
I don't think there's much value in adding an Annex K comparison anywhere since none of the compared libcs have Annex K functions; comparison items are only meaningful where they differ. Even if some libcs did have it, though, I'd be hesitant to put it under hardening. My concept of "hardening" is providing additional properties beyond the scope of the specification (usually this means in places where undefined behavior occurs, but it could also be implementation-defined things, such as using an alternate pointer representation that allows as much bounds-checking as C makes possible).
dalias··on Comparison of C/Posix standard library implementations for Linux
Could you clarify what you mean by "doesn't support aarch32"? I can't find any clear definition of what aarch32 means, but my impression is that it's just a new name for what we call "arm", but possibly implying new instructions available on v8, and the ABI is the regular 32-bit ARM EABI. If so musl supports it just fine.
dalias··on Comparison of C/Posix standard library implementations for Linux
I don't think Bionic is really suitable for this. It's unlikely to even work for building apps that weren't specifically designed for Bionic, since it's rather deficient in its support for many of the standard functions, and also differs moderately from glibc and other more popular libcs in the extensions it provides. Really Bionic was just created to be the minimal libc needed to run Dalvik (Google's "JVM") and everything else looks like an afterthought. I'd really like to add Bionic to the comparison table, but I haven't found a way to build it outside of building a whole Android development environment, which is a huge headache...
dalias··on Broken by design: systemd
Folks on #musl found 2 integer overflow bugs in the UTF-8 handling code within seconds of checking out the source to read it. It's not clear to me where the code is called from and what inputs reach it, but that kind of bug does not inspire confidence in the safety of the project as a whole. I also quickly found a case where a potentially-null string pointer is passed to a logging function which might or might not be able to accept null string pointers. (I suspect it uses snprintf and therefore depends on the underlying C library's handling of this usage, which is undefined behavior.)
dalias··on Broken by design: systemd
Functionality is not being moved out of the kernel and into userspace. It's being moved out of legacy freedesktop.org components (hald, ConsoleKit, PolicyKit, etc.) and into PID 1. Where should it be moved to? /dev/null.
dalias··on Broken by design: systemd
Almost all daemons have a command line or config file option to skip "daemonizing" so that the parent can watch the PID correctly. For the few that don't, you can fix them, hack them (e.g. LD_PRELOAD wrappers to shutdown their bogus double-forking), seccomp-ptrace them, or simply wrap them with a legacy-style monitor that reads the pid file and forwards signals it receives to the real pid (this last option of course doesn't fix the race conditions inherent in such usage).
dalias··on Musl libc
The lore is that the the name POSIX, not the idea for POSIX, came from RMS and was a form of disguised spite for the process (i.e. that he intended it to be read as Piece Of Shit *IX, or similar). I'm not sure whether there's any evidence to corroborate this part of the lore, but in the early days POSIX was definitely not representative of RMS's ideas/vision. These days the standards process and even the document itself are a lot more open (though still not up to RMS's standards).

CHAR_BIT==8 was not mandated by POSIX until 2001 when it was aligned with C99, and seems to have been mandated as a consequence of C99's requirement that [u]intXX_t types not have any padding bits, and the requirement (in POSIX) that network-related interfaces use uint8_t, uint16_t, and uint32_t (which, per C99, cannot all exist unless CHAR_BIT==8).

dalias··on Musl libc
Machines with a word size that's not a multiple of 8 cannot support POSIX at all. POSIX requires CHAR_BIT==8, and to support the POSIX and C11 memory model for threads, bytes must be individually addressible without a read-modify-write cycle on a larger memory unit. So this kind of thing really is irrelevant as far as POSIX is concerned.
dalias··on Musl libc
The glibc default thread stack size is unacceptable/broken for a couple reasons. It eats memory like crazy (usually 8-10 megs per thread), and by memory I mean commit charge, which is a highly finite resource on a well-configured system without overcommit. Even if you allow overcommit, on 32-bit systems you'll exhaust virtual memory quickly, putting a low cap on the number of threads you can create (just 300 threads will use all 3GB of address space).

With that said, musl's current default is way too low. It's caused problems with several major applications such as git. We're in the process of trying to establish a good value for the default, which will likely end up being somewhere between 32k and 256k. I'm thinking 80k right now (96k including guard page and POSIX thread-local storage) but I would welcome evidence/data that helps make a good choice.

dalias··on Musl libc
Addressing afhof's comments...

1 & 2. I don't see any reason to believe there will ever be a new machine with non-power-of-two word size, and I'm doubtful that there are even any historical post-standardization C implementations like that. Certainly Linux, which makes much bigger assumptions about word size and the relationship of types, will never support such hypothetical systems. Generality is good if it buys you anything practical, but my approach has been to avoid excess generality unless it has a practical benefit. This approach has been very beneficial in the dynamic linker, wherein assuming that things that are the same on real-world archs actually are the same, the amount of per-arch code to maintain is only some 30 lines (which might grow to 60-100 once TLS is supported), as opposed to many hundreds or even thousands in other implementations.

At this point, musl does not have official documentation/manual. When it does, these sorts of requirements as well as all the implementation documentation required by ISO C and POSIX will be documented.

3. The casts are all necessary (C does not define implicit conversions between pointer types) and correct. Casting to (void *) rather than an explicit type is my preference because it reduces duplication of the type in multiple places, but in any case this is purely a stylistic matter and has nothing to do with the generated code or correctness.

4. The ONES macro was leftover from other files on which this code was based (strchr and strcpy). Obviously it's not needed in memcpy which copies a fixed number of bytes without searching for any terminator character, so it could/should be removed. Thanks for catching this.

← PreviousPage 2 of 2