Problems with __cxa_demangle and the verbose terminate handler

Andreas Schwab schwab@suse.de
Tue Feb 24 11:05:00 GMT 2004


Mark Mitchell <mark@codesourcery.com> writes:

> Perhaps most dangerous of all is this code in vterminate.cc:
>
>   # define writestr(str)  write(2, str, __builtin_strlen(str))
>
> This bit of cleverness is designed to let the terminate handler write
> to the standard error stream.  However, there is no way to know that
> file descriptor 2 *is* the standard error stream.  If the process
> closes stderr, and then opens another file (say, "/dev/launch_missle",
> or "/dev/database") that new file descriptor may very well be
> descriptor 2.  Using "fputs" to write to "stderr" does not have this
> problem.

POSIX defines STDERR_FILENO to 2, so both are required to be equivalent.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Libstdc++ mailing list