[libcxx-commits] [PATCH] D65667: [libcxx] Early-initialize error_category singletons

Hubert Tong via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Aug 7 14:27:07 PDT 2019


hubert.reinterpretcast added a comment.

In D65667#1619105 <https://reviews.llvm.org/D65667#1619105>, @mclow.lists wrote:

> Thanks for the clarification.
>
> So the situation is:
>
> - You register an `atexit` handler.
> - During program termination, your handler is called, and you do something that creates an `error_code` object.
> - You try to use the `error_category` of that error code, and discover that it has been destroyed?
>
>   Is that correct?


We did not hit the `atexit` handler case. We had a static lifetime object (the one returned by `llvm::errs()`) that holds an `error_code` (`llvm::raw_fd_ostream::EC`) as a member. The `error_code` is assigned to during the course of the program. When the destructor for the `llvm::raw_fd_ostream` is called, we discover that we can't use the `error_categoy` of the error code (because it has been destroyed).


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65667/new/

https://reviews.llvm.org/D65667





More information about the libcxx-commits mailing list