From c5c3f9f85b52d5e5aa0399c0fdce9916ede1c393 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Wed, 30 Apr 2014 09:40:08 -0700 Subject: [PATCH] race in Future destructor MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- folly/wangle/Future-inl.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/folly/wangle/Future-inl.h b/folly/wangle/Future-inl.h index 0e19cc79..e563b86b 100644 --- a/folly/wangle/Future-inl.h +++ b/folly/wangle/Future-inl.h @@ -44,11 +44,7 @@ Future& Future::operator=(Future&& other) { template Future::~Future() { if (obj_) { - if (obj_->ready()) { - delete obj_; - } else { - setContinuation([](Try&&) {}); // detach - } + setContinuation([](Try&&) {}); // detach } } -- 2.34.1