Fix lifetime issue in coro::Materialize with active union member
Summary: `folly::coro::Materialize` uses a `union` of `ManualLifetime` objects to store either the result (value) or the error of an async operation. However, it accesses these fields without ever activating them by in-place constructing the `ManualLifetime` objects. Likewise, when changing the active field, the `ManualLifetime` objects must by destroyed. It doesn't matter that these operations are no-ops. The must be there to avoid UB, which can manifest at higher optimization levels. I fix this by providing two functions: `activate` and `deactivate`, for use constructing and destructing values in `ManualLifetime` objects when those objects are fields in a `union`. Reviewed By: yfeldblum, kirkshoop Differential Revision: D22527895 fbshipit-source-id: 8cc1c3fae75672387d977dddeff61c82093abb9a
Showing
Please register or sign in to comment