aboutsummaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.cpp
diff options
context:
space:
mode:
authorDaniele Di Proietto <ddiproietto@google.com>2021-10-06 15:19:30 +0100
committerDaniele Di Proietto <ddiproietto@google.com>2021-10-07 17:25:00 +0100
commitb6d3c782445b08cc0e4ec942dd8ebb3f138dc245 (patch)
treeb3080489d2493da3f7b2e6fcd593545c70f0ddfb /libc/stdio/stdio.cpp
parent617c4b5876e6b572f08461fead9e5f519027250d (diff)
malloc_heapprofd: Avoid a spurious error log
In the following scenario: * Heapprofd wants to profile a process. * The process receives the heapprofd signal, so it sets up the ephemeral hooks. * The process does not perform any allocation, so the proper heapprofd hook is never installed. * Heapprofd terminates. * Now heapprofd wants to start a new profiling session. * The process receives the heapprofd signal (again). In the signal handler, no action is needed at this point. The ephemeral hooks are already setup, so, at the next malloc, the proper heapprofd hooks will be installed. Before this commit, the code logged an error message, but still worked correctly. This commit basically just skips the error_log below. Example of the error message that is now suppressed: ``` process: heapprofd: failed to transition kInitialState -> kInstallingEphemeralHook. current state (possible race): 2 ``` Tested by: * Running a process that calls malloc on input from stdin. * (Optional, tested both cases) Enable GWP-Asan by calling `android_mallopt(M_INITIALIZE_GWP_ASAN, ...`. The call will return success. * Attaching heapprofd: ``` external/perfetto/tools/heap_profile -i 1 -p `adb shell pidof <...>` ``` * Detaching heapprofd (CTRL-C). The trace will be empty. * (If not enabled before) Enabling GWP-Asan. The call will fail (because GWP-Asan detects heapprofd hooks). * Reattaching heapprofd. * Triggering some malloc()s in the process. The error log from above will not appear in `adb logcat`. * Detaching heapprofd (CTRL-C). The trace will NOT be empty. Bug: 192258849 Change-Id: I01699b10ecd19e52e1e77f83fcca955ebd885942
Diffstat (limited to 'libc/stdio/stdio.cpp')
0 files changed, 0 insertions, 0 deletions