There is a race condition in ASAN where it can perform the leak detection before all detached threads exit and free their resources. This can lead to failures in the future tests.
This patch fixes the race condition my manually joining all threads that are used. This patch should not affect the functionality of the tests.
Details
- Reviewers
mclow.lists danalbert jroelofs
Diff Detail
Event Timeline
So 4 things:
- I'm a little out of my comfort zone with this thread stuff... pretty far from my area of expertise
- Perhaps you missed a few, for example: thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp (grep for 'detach' in tests).
- Doesn't this reduce the test coverage for the thread.detach() method?
- I *really* *really* don't like the idea of changing tests to push bugs under the rug. It'd be much better to 'XFAIL: asan' these. I have a thought on how to fix asan that I'll add to the PR.
Cheers,
Jon
I *really* *really* don't like the idea of changing tests to push bugs under the rug. It'd be much better to 'XFAIL: asan' these. I have a thought on how to fix asan that I'll add to the PR.
Agreed.
Erm, nevermind, my idea won't work (for the record, it was something to do with -Wl,--wrap,atexit). This still makes me uncomfortable.
I left those out on purpose since the value should not be set until the thread cleans up and exits. So there should be no race condition.
- Doesn't this reduce the test coverage for the thread.detach() method?
These tests are not intended to test thread.detach(). detach() should be thoroughly tested elsewhere but I'll double check.
- I *really* *really* don't like the idea of changing tests to push bugs under the rug. It'd be much better to 'XFAIL: asan' these. I have a thought on how to fix asan that I'll add to the PR.
Me too. The initial response to the PR was that this might not be fixable and we don't want tests that occasionally fail with ASAN. We can't XFAIL these tests because they pass 90% of the time. We could mark them as UNSUPPORTED but then you lose test coverage with ASAN. Since the above changes should not change the functionality of the tests I think this is the best approach.
I, too, would much prefer a fix to ASAN, and/or a way to XFAIL them.
[ But I did note that this is an "intermittent failure" under ASAN ]
Lets hold off for a couple of days to see if this can be fixed in ASAN then. Otherwise I don't see another option.