Commit bfdcacf9 authored by Erik Hortsch's avatar Erik Hortsch Committed by Facebook Github Bot

Check that fiber suspends are not occuring in exception catch blocks

Summary:
Fiber suspends are incompatible with C++ exception handling. We should enforce that callers are not suspending fibers while handling exceptions.
See https://fb.facebook.com/groups/560979627394613/permalink/1119586164867287/

NOTE: This check currently fires not just for baton.wait() (and all things based on baton), but also for calling runInMainContext. I'm unsure of the safety of this.

Reviewed By: yfeldblum

Differential Revision: D6695110

fbshipit-source-id: cf36edbab9f0573cbf639bf79d0c267681ac5914
parent 169e1f02
...@@ -350,6 +350,13 @@ constexpr auto kMscVer = _MSC_VER; ...@@ -350,6 +350,13 @@ constexpr auto kMscVer = _MSC_VER;
#else #else
constexpr auto kMscVer = 0; constexpr auto kMscVer = 0;
#endif #endif
// TODO: Remove when removing support for gcc4.9
#if __GLIBCXX__ && __GLIBCXX__ == 20150123
constexpr auto kIsGlib49 = true;
#else
constexpr auto kIsGlib49 = false;
#endif
} // namespace folly } // namespace folly
// Define FOLLY_USE_CPP14_CONSTEXPR to be true if the compiler's C++14 // Define FOLLY_USE_CPP14_CONSTEXPR to be true if the compiler's C++14
......
...@@ -170,6 +170,9 @@ void Fiber::preempt(State state) { ...@@ -170,6 +170,9 @@ void Fiber::preempt(State state) {
DCHECK_EQ(fiberManager_.activeFiber_, this); DCHECK_EQ(fiberManager_.activeFiber_, this);
DCHECK_EQ(state_, RUNNING); DCHECK_EQ(state_, RUNNING);
DCHECK_NE(state, RUNNING); DCHECK_NE(state, RUNNING);
DCHECK(!std::current_exception());
// std::uncaught_exception is broken in libstdc++ v4.9
DCHECK(kIsGlib49 || !std::uncaught_exception());
state_ = state; state_ = state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment