commit | bd3e8ecca937a76318c68ec8e8da72cb5c0239ba | [log] [tgz] |
---|---|---|
author | Primiano Tucci <primiano@google.com> | Mon Jun 29 11:28:58 2020 +0100 |
committer | Primiano Tucci <primiano@google.com> | Mon Jun 29 11:28:58 2020 +0100 |
tree | 0ab0599b64a0dcdfd157327a60f00b4e21087fc7 | |
parent | 8c03b409fdb2f717b3de733b8468457f65c9b027 [diff] |
ftrace: fix pointer stability of events_ vector This fixes an extremely subtle bug which causes traced_probes to crash when tracing on some specific devices. The root cause of the bug is the fact that in rare cirumstances the events_ vector can be resized after construction, after some Event* poitners have been handed out, hence invalidating them. The rare circumstance is: - The trace config ends up hitting a "generic event" path, i.e. the ftrace event is not known at compile time but exists on the target device (note this is not that unlikely because the expansion of some atrace categories in ftrace_config_muxer.cc can end up adding events like sde/sde_cmd_release_bw which are not in the compile-time list. - The ftrace event ID of the generic event above is > than the max(ID of events known at compile time) - The vector resize() ends up hitting the unhappy realloc() path which changes the data() pointer and mem-copies everything, invalidating all pointers. Fix: use std::deque, which guarantees pointer stability. Bug: 159998308 Change-Id: Id21fabf0c940fd0e5302518c0170686d61aaf847
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.