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

Andus Yu via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 2 11:18:20 PDT 2019


andusy created this revision.
andusy added reviewers: hubert.reinterpretcast, jasonliu, mclow.lists.
andusy added a project: libc++.
Herald added a reviewer: EricWF.
Herald added subscribers: ldionne, christof.

When a handle to an error_category singleton object is used during the termination phase of a program, the destruction of the error_category object may have occurred prior to execution of the current destructor or function registered with `atexit`, because the singleton object may have been constructed after the corresponding initialization or call to `atexit`. For example, the updated tests from this patch will fail if using a libc++ built using a compiler that updates the vtable of the object on destruction. This patch attempts to avoid the issue by triggering the construction of the singleton objects during the initialization of non-local objects of static storage duration from the library. This approach might not work on platforms where such initialization is delayed.


Repository:
  rCXX libc++

https://reviews.llvm.org/D65667

Files:
  libcxx/src/future.cpp
  libcxx/src/ios.cpp
  libcxx/src/system_error.cpp
  libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
  libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
  libcxx/test/std/input.output/iostreams.base/std.ios.manip/error.reporting/iostream_category.pass.cpp
  libcxx/test/std/thread/futures/futures.errors/future_category.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65667.213076.patch
Type: text/x-patch
Size: 5457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190802/1cd99724/attachment.bin>


More information about the libcxx-commits mailing list