[llvm-commits] [PATCH] report_fatal_error() issue

Dan Gohman gohman at apple.com
Thu Feb 3 10:38:03 PST 2011


On Feb 2, 2011, at 5:22 PM, NAKAMURA Takumi wrote:

> Dan, thank you to comment me!
> 
> I met this issue with test/Others/close-stderr.ll on mingw MSYS bash shell.
> 
> 2011/2/3 Dan Gohman <gohman at apple.com>:
>> If there's a real bug here, please explain it.  Otherwise, this seems to be
>> some Windows quirk, so it should be conditionalized with #if accordingly.
>>  In either case, please add a comment in the code.
> 
> I was dubious to invoke exit() in global dtors.
> I have reconfirmed "exit() in global dtor" works on glibc2 linux.

With the current code, output errors in raw_fd_ostream never pass
silently, unless explicitly silenced. If you know of a better way to
achieve this, please suggest it.

> I have to conditionalize when we can expect it above. eg.
> #ifdef __MINGW32__
>  // Mingw is not expected to call exit() in dtor context.
>  return;
> #endif
>  if (has_error()) report_fatal_error(…);

With this approach, command-line tools like opt, llc, etc., will
silently swallow all output errors on mingw. I'll leave it up to you.

> On mingw, global dtors are called as atexit handlers. (not cxa_atexit)
> And it seems atexit() would not be re-entrant.
> 
> Anyway I thought report_fatal_error() would be futile when stderr got
> fault (FD == 2).


If stderr has seen an output error, something bad must have happened.
Even though report_fatal_error's own message may not get through, its
other effects are still useful.

Dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110203/0c4bdf4f/attachment.html>


More information about the llvm-commits mailing list