|Summary:||undefined behavior when porting error()|
|Product:||glibc||Reporter:||Eric Blake <ebb9>|
|Component:||libc||Assignee:||Not yet assigned to anyone <unassigned>|
Avoid undefined behavior in error().
update patch to work on mingw
update patch to take into account possible freopen(stdout) calls
Description Eric Blake 2009-07-18 13:13:19 UTC
Within glibc, it is always safe to call fflush (stdout), even if stdout has been previously closed. However, POSIX does not require this guarantee, and there are other platforms where attempting a flush in this situation causes a SIGSEGV: http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/18046/focus=18052 Since gnulib ports the error.c file to many other platforms, but wants to keep it in sync with glibc's version, it would be nice for glibc to apply this patch for portability. The attached patch makes the optimization of not calling fcntl on glibc, while still fixing the crash from the original gnulib report.
Comment 1 Eric Blake 2009-07-18 13:14:21 UTC
Created attachment 4060 [details] Avoid undefined behavior in error().
Comment 2 Eric Blake 2009-07-18 13:38:31 UTC
Created attachment 4061 [details] update patch to work on mingw