On Mon, Jan 31, 2022 at 8:48 PM Peter Dimov via Boost
This causes problems if an exception is captured, rethrown, caught and modified, then rethrown again using the same exception_ptr. The second rethrow throws the modified exception.
There is an additional problem in that things go kaboom if the error info map ends up being accessed concurrently. The way this situation is avoided by boost::current_exception (which predates std::current_exception) is a bit tricky: - The error info map is allocated separately from the exception object and held in a custom (non-thread-safe) reference counting smart pointer stored in the boost::exception base, so copies of the exception object created by the copy constructor share the same map. This is done for efficiency (remember, the library is very old), and because it does not interfere with the normal use of boost::exception within a single thread. - When we make a boost::exception_ptr (via boost::current_exception), the boost::exception base is recognized automatically, and the error info map is copied. Thus, the new exception object held by boost::exception_ptr has its own separate error info map and it is safe to rethrow it in another thread (the standard specifies that current_exception is allowed to make a copy or not).