From fd915b73606e09a5f46a1bca0a5d3643a1567014 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Tue, 21 Oct 2014 15:50:02 -0700 Subject: [PATCH] (wangle) fix after-delete assert Summary: This would cause debug builds to do a bad thing (access the variable `this->detached_` within an assert, after `delete this`). Test Plan: unit tests Hopefully now that we have a dummy cpp file in `folly/wangle/detail` contbuild will pick it up and all the dependencies will also run their tests. Right now, we suspect maybe maelstrom (@wez) and adinvoicer and zookeeper (@jying) and probably others are seeing this in unit test failures (esp. if they use asan, which is rightly detecting read after free). Hoping contbuild will catch them. Reviewed By: davejwatson@fb.com Subscribers: net-systems@, fugalh, exa, njormrod, folly-diffs@, wez, dcapel, jying, cgheorghe FB internal diff: D1630301 Tasks: 5424546, 5435720 Blame Revision: D1618240 --- folly/wangle/detail/Core.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/folly/wangle/detail/Core.h b/folly/wangle/detail/Core.h index d45b985d..9b9295d8 100644 --- a/folly/wangle/detail/Core.h +++ b/folly/wangle/detail/Core.h @@ -205,12 +205,13 @@ class Core : protected FSM { } void detachOne() { - if (++detached_ == 2) { + ++detached_; + assert(detached_ == 1 || detached_ == 2); + if (detached_ == 2) { // we should have already executed the callback with the value assert(calledBack_); delete this; } - assert(detached_ == 1 || detached_ == 2); } folly::Optional> result_; -- 2.34.1