A debugging story comparing glibc and musl libc implementations of isalnum. A SIGSEGV was triggered in scdoc when passing a UCS-32 codepoint to isalnum on glibc but not musl. The root cause is glibc's isalnum implementation using a locale-based lookup table with pointer dereferences, which segfaults on out-of-range values. Musl's implementation uses simple arithmetic and never segfaults. While the C spec technically requires isalnum to only receive unsigned char values or EOF, the author argues glibc's design is needlessly complex and fragile compared to musl's clean, safe implementation.
Sort: