(wangle) fix a race in whenAll
authorHans Fugal <fugalh@fb.com>
Wed, 5 Nov 2014 19:21:49 +0000 (11:21 -0800)
committerPavlo Kushnir <pavlo@fb.com>
Sat, 8 Nov 2014 02:37:27 +0000 (18:37 -0800)
commit20dfb55adcc0c87f596047a6b3614cc36583808b
tree7870cdd4d5622daba80058814d9b05966a0973a3
parent773fa87ac372ce5c920d3caf1021656145f2b00f
(wangle) fix a race in whenAll

Summary:
Race in `++ctx->count == ctx->total`. This ordering, while not very obvious or likely, is possible:

T1            T2
--            --
++ctx->count
++ctx->count
ctx->total
==
setValue
delete ctx
ctx->total
==
setValue
delete ctx

Test Plan:
That's the idea, anyway. I need some sleep, and it takes 20 minutes to build and test. I had a more convoluted fix (using `shared_ptr`) and it did seem to fix the error we were seeing, but I was seeing another error.

Reviewed By: darshan@fb.com

Subscribers: trunkagent, net-systems@, fugalh, exa, njormrod, folly-diffs@

FB internal diff: D1660663

Tasks: 5506504

Signature: t1:1660663:1415207632:49dc224363cec27736fc71fb211fa846be9e170f

Blame Revision: D1636487
folly/wangle/Future-inl.h
folly/wangle/detail/Core.h