Fix crash in exception_wrapper::get_exception<>
Summary:
[Folly] Fix crash in `exception_wrapper::get_exception<>`.
When the contained object is unthrown and does not inherit `std::exception`, `get_exception` templated over a type that does not inherit `std::exception` must throw and catch internally and may then return a pointer to the internally thrown object, which has since been deallocated.
Attempting to dereference that pointer is undefined behavior is correctly caught by ASAN as heap-use-after-free.
Fix it by storing objects not inheriting `std::exception` using only the `std::exception_ptr` representation.
As a downside, we no longer get the small-object optimization or the non-throwing optimization for objects which do not inherit `std::exception`. But this is not likely to be terribly concerning in practice.
Reviewed By: ericniebler
Differential Revision:
D6504911
fbshipit-source-id:
0065de911733b5cab87be55e7e4e47f0a9c09140