[sampling heap profiler] Fix a deadlock.
Profiler functions used to lock the mutex first and then update the entered_
TLS variable. That caused the following sequence leading to a deadlock:
1. In DoRecordAlloc it locks the mutex and then calls entered_.Set(true)
2. If this happens to be the very first access to TLS, it causes internal
TLS vector to be allocated.
3. It then reenters DoRecordAlloc, the entered_.Get() is still false since #1 is
not yet finished.
4. Thus it proceed to locking the mutex again.
The fix is basically swapping the order of mutex locking and entered_.Set(true).
BUG=842396
Change-Id: I926c05755321c082215ca84bfc312348c89ecdca
Reviewed-on: https://chromium-review.googlesource.com/1056412
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558122}
CrOS-Libchrome-Original-Commit: 0bd4e5d3ea0f9c268f1685c061843c4e924c7504
1 file changed