Sourceware Bugzilla – Bug 14250
ia64 makecontext.c writes to stderr and it should not.
Last modified: 2012-06-18 21:41:54 UTC
The implementation of makecontext() for ia64 (ports/sysdeps/unix/sysv/linux/ia64/makecontext.c) writes to stderr if there are more than 8 arguments.
The function should not write to stderr, see bug #13983 for some background. Instead the function should set errno and return.
Unfortunately POSIX doesn't seem to dictate any errno for makecontext(), almost as if it should never fail. This is IMO an oversight, we should return EINVAL when > 8 arguments. At least IBM's XL C runtime returns EINVAL with invalid argc.
We must strive for a high QoI and avoid arbitrarily writing to stderr.
i did see this failure, but was trying to figure out how to make it work. i'm not really worried about the stderr write ... the fact that it calls exit() seems like a much worse violation.
i could have it setup the context in such a way that when it calls setcontext, that function would return an error ...
I didn't notice the call to exit(). Calling exit() is definitely the wrong thing to do in this context.
Returning EINVAL when argc > 8 would fix both of these problems.
I wonder if you couldn't somehow macro-ize this to fail at build time if argc was greater than 8?
It's possible to make it fail at compile-time using macros if the function is called directly, but this won't catch all cases, such as calls to makecontext via a function pointer or when the caller prototypes the function without including the header. The test at runtime is really necessary.