fix potential race/memory corruption in IOThreadPoolExecutor
Summary: In unusual but possible circumstances, the EventBase and thus pending tasks will outlive the pool, so we shouldn't keep references of any kind to the pool in the task. The only reference we were keeping was used to access the task stats rx subject. Store the subject as a shared ptr and give a copy of the ptr to the Thread object, which is itself owned by a shared ptr and captured by every task. I thought this had to do with the thread local leak in mentioned in the test plan of D1682860 but this patch doesn't actually fix that :( Thankfully, while task surfing I saw @phillip's awesome D1682698. Patching that in fixes the leak! Woo. Either way, this is more correct. Test Plan: unit under clang/asan Reviewed By: davejwatson@fb.com Subscribers: trunkagent, fugalh, njormrod, folly-diffs@, philipp FB internal diff: D1683221 Tasks: 5336655 Signature: t1:1683221:1416264933:946d29b5a3eb22ed08812f2adefb7284b1899e4e
Showing
Please register or sign in to comment