commit | ecc7f22b311c5ce55f6c0f081adc660edfc21e13 | [log] [tgz] |
---|---|---|
author | Sami Kyostila <skyostil@chromium.org> | Wed May 05 18:37:46 2021 +0000 |
committer | Sami Kyostila <skyostil@google.com> | Thu May 06 12:27:15 2021 +0000 |
tree | d349a0b36e977716df341dc7d4841166d7dcff41 | |
parent | 9d7fd31b50330f79a861d00bdb3f9d429300300f [diff] |
tracing: Guard against task runner re-entrancy Disable data source trace points on the calling thread while a task is being posted by the tracing muxer. This avoids a situation where the user-provided platform task runner implementation tries to enter a trace point under the hood, causing unexpected re-entrancy to the muxer or other parts of the tracing library. An example re-entrancy chain in Chrome looks like this: 1. Start a tracing session through the consumer interface. 2. ConsumerEndpointImpl::AddObservableEvents 3. base::tracing::PerfettoTaskRunner::PostTask 4. base::ScopedDeferTaskPosting::PostOrDefer 5. base::TaskAnnotator::WillQueueTask (We hit a trace event here, but it's not currently filtered out since we're not a in a trace event yet.) 6. perfetto::internal::TracingMuxerImpl::CreateTraceWriter 7. perfetto::SharedMemoryArbiterImpl::CreateTraceWriter 8. base::tracing::PerfettoTaskRunner::PostTask ==> Crash because base::DeferredSequencedTaskRunner isn't re-entrant. Bug: 180295966 Change-Id: I3f283d922cedd07d994c7ccf14102d659e44c7ac
Perfetto is a production-grade open-source stack for performance instrumentation and trace analysis. It offers services and libraries and for recording system-level and app-level traces, native + java heap profiling, a library for analyzing traces using SQL and a web-based UI to visualize and explore multi-GB traces.
See https://perfetto.dev/docs or the /docs/ directory for documentation.