[Toybox] [PATCH] timeout.c: fix for macOS.
Rob Landley
rob at landley.net
Thu Aug 25 03:31:55 PDT 2022
On 8/24/22 19:31, enh via Toybox wrote:
> I don't know why we get away with this on Linux, but macOS really
> means business with the "values of objects of automatic storage
> invocation duration that do not have the volatile type and have
> been changed between the setjmp() invocation and longjmp() call are
> indeterminate" thing, leading to bad fds and a bad pid.
Their setjmp() isn't annotated with attribute((__returns_twice__)). Musl had
that problem with vfork() once upon a time. Rich fixed it:
https://landley.net/notes-2017.html#03-02-2017
Sigh. Applied. (And then I patched on top if it because TT starts zeroed so you
don't need to set fd[0] to 0. Don't think I broke anything but can't test mac.)
> Using
> volatile causes lots of warnings about passing `volatile int*`
> instead of `int*`, so it's a smaller change to move the fields into
> TT (and avoid the "automatic storage" part) than it is to add the
> `volatile` modifier.
>
> Four timeout tests fail on macOS (both locally and on github's CI)
> without this patch, and all timeout tests pass on macOS with this
> patch.
Got it. I still consider this a mac bug, but technically it's "lack of
longstanding gcc extension use in their libc". Roughly on the level of not
having the empty (x ? : y) extension...
(Someday, the C standards committee may catch up, but I expect Planck's
principle to be involved if so.)
Rob
More information about the Toybox
mailing list