Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid leaking thread names at thread exit
Summary: gcc 5 on travis had an asan reported error: ``` ==11639==ERROR: LeakSanitizer: detected memory leaks Direct leak of 13 byte(s) in 1 object(s) allocated from: #0 0x2b0094f9657a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9757a) #1 0x2b009691ffe7 in vasprintf (/lib/x86_64-linux-gnu/libc.so.6+0x71fe7) SUMMARY AddressSanitizer: 13 byte(s) leaked in 1 allocation(s). FAIL: tests/future.t 1..17 ok 1 - some/path expected=0 actual=0 ok 2 - buck-out/gen/foo expected=1 actual=1 ok 3 - .hg/wlock expected=0 actual=0 ok 4 - .hg/store/foo expected=1 actual=1 ok 5 - buck-out expected=1 actual=1 ok 6 - foo/buck-out expected=1 actual=1 ok 7 - foo/hello expected=0 actual=0 ok 8 - baz/hello expected=0 actual=0 ok 9 - .hg expected=0 actual=0 ok 10 - buil expected=0 actual=0 ok 11 - build expected=1 actual=1 ok 12 - build/lower expected=1 actual=1 ok 13 - builda expected=0 actual=0 ok 14 - build/bar expected=1 actual=1 ok 15 - buildfile expected=0 actual=0 ok 16 - build/lower/baz expected=1 actual=1 ok 17 - builda/hello expected=0 actual=0 ``` looking at the code, we now only use vasprintf in the TAP test harness and for thread names. We only register a dtor for the thread local storage on darwin, which doesn't support C++11 thread_local storage duration. Since windows doesn't have pthread_setspecific we do prefer a solution that works with the C++11 thread_local storage duration, so this diff changes the type of the thread local to std::string on everything other than darwin, so that its dtor will run at the appropriate time. Differential Revision: D5101485 fbshipit-source-id: d7fd37bdcb8c3928b53b27dd617f3aa41cc919fa
- Loading branch information