Hash :
f8fd9cfb
Author :
Date :
2020-06-09T10:52:57
Fix racy GetCategory with trace_event
See racy trace_event:
http://crbug.com/1091723
The trace event macros were racy because of this code:
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(...)
The macro is using a static variable which is not thread-safe.
The design of tracing was racy (by design) and rely on
the fact that addTraceEvent(...) is threadsafe internally via
TraceLog::lock_
This CL is replacing the static variable with a scope (C++11)
pattern. The static variable is guaranted (C++) to be atomic
and it is implemented efficiently.
see: ยง6.7 [stmt.dcl] p4
" If control enters the declaration concurrently while the
variable is being initialized, the concurrent execution
shall wait for completion of the initialization. "
Bug to track follow-up migration:
http://anglebug.com/4702
Bug: chromium:1091259, chromium:1091723
Change-Id: If67b501e6e826ccf603eb2349c3f0aa6272c9a52
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2233410
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>