Module Name: src Committed By: riastradh Date: Sat Mar 29 01:06:37 UTC 2025
Modified Files: src/lib/libc/gen: isctype.c src/tests/lib/libc/gen: t_ctype.c Log Message: ctype(3): Summon a demon from caller's nose if abused out-of-line. This way, applications which opt for the out-of-line functions will crash with a potentially meaningful message to stderr if they pass inputs on which the ctype(3) functions are undefined. (If fd 2 is something else, tough -- this is nasal demon country, and they fly where they please, application intent be damned.) This probably won't catch many applications -- but it might catch C++ applications at runtime that can't be caught at build-time because they eschew the macros. The cost is a single predicted-not-taken branch -- it's checking c for membership in the interval [-1,0xff] when we're already computing c + 1, so it can be a single unsigned-compare. By deferring the message and abort to an out-of-line function we avoid a stack frame in the good case. And this is for the unlikely, out-of-line versions of the ctype(3) functions -- most applications get the inline macros. So I'm not concerned by the prospect of a performance impact. Update the tests so they recognize SIGABRT as noisy failure too, not just SIGSEGV. PR lib/58208: ctype(3) provides poor runtime feedback of abuse To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libc/gen/isctype.c cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/gen/t_ctype.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.