Commit c5c3f9f8 authored by Hans Fugal's avatar Hans Fugal Committed by Dave Watson

race in Future destructor

Summary:
@mnd wrote some Wangle code that would trip up with a `bad_function_call` exception. This Shouldn't Happen but the exception comes from trying to call a `std::function` which is null. We pretty thoroughly examined his usage and didn't find any problems, and this patch seems to make the error go away. See #4207781 for more details.

And reasoning about it, it makes sense. Inline comments explain the race.

Test Plan: Alas, I haven't been able to get a minimal repro and therefore a regression unit test. It's a hard race to trigger. I still don't understand why Matt's code does it.

Reviewed By: davejwatson@fb.com

FB internal diff: D1304001
parent 57027681
...@@ -44,11 +44,7 @@ Future<T>& Future<T>::operator=(Future<T>&& other) { ...@@ -44,11 +44,7 @@ Future<T>& Future<T>::operator=(Future<T>&& other) {
template <class T> template <class T>
Future<T>::~Future() { Future<T>::~Future() {
if (obj_) { if (obj_) {
if (obj_->ready()) { setContinuation([](Try<T>&&) {}); // detach
delete obj_;
} else {
setContinuation([](Try<T>&&) {}); // detach
}
} }
} }
......
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