summaryrefslogtreecommitdiff
path: root/debuggerd/handler/debuggerd_fallback.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update for SetProcessMemory removal.Christopher Ferris2022-04-191-3/+2
| | | | | | | Bug: 120606663 Test: All unit tests pass. Change-Id: Icf8a3ceb75b8962f8f215501c2bac631b40a1527
* Dump threads in tombstone fallback path.Christopher Ferris2022-02-161-44/+17
| | | | | | | | | | | | | | | | | | | | | When dumping a tombstone using the fallback path, only the main thread was showing up. Modify the code to dump the threads using a slightly different path for the tombstone generation code. In addition, while looking at this code, two MTE variables were not set in the tombstone fallback code. Added those variables so MTE devices will work properly in this fallback path. Modified the tombstone unit tests for seccomp to have multiple threads and verify those threads show up in the tombstone. Bug: 208933016 Test: Ran unit tests. Test: Ran debuggerd <PID> on a privileged process and verified Test: all threads dumped. Also verified that the tagged_addr_ctrl Test: variable is present on the raven device. Change-Id: I16eadb0cc2c37a7dbc5cac16af9b5051008b5127
* debuggerd: unify licenses.Elliott Hughes2021-06-181-23/+11
| | | | | | | | All but three files are Apache-2.0 already. Bug: http://b/191499510 Test: /google/src/files/head/depot/google3/wireless/android/busytown/ayeaye/analyzers/copyright/tools/scan_android_project.sh ~/aosp/system/core/debuggerd/ | grep -v APACHE Change-Id: I430c3382dd160e398f02470d7053ecea39c98f41
* Avoid thread cache in unwinder.Christopher Ferris2021-06-141-0/+6
| | | | | | | | | | | | | | | | The code in the fallback path calls pthread_key_create when using the normal thread cache. However, this code is executed out of the linker, which means that the call doesn't see keys created by the libc version of pthread_key_create. As of now, simply avoid using the thread cache to avoid this problem. Bug: 189803009 Test: debuggerd -b on a media process on a 32 bit Android Go device Test: and observe no crash. Test: debuggerd unit tests pass. Change-Id: I9ca1a55e44d3bb69d49450826d7d64d7a64145c3 (cherry picked from commit 49e5a765440604eac1208c831c1cd8c0f97cb09e)
* Reland protobuf tombstones.Josh Gao2021-01-261-9/+10
| | | | | | | | | | | | | This reverts the following commits: e156ede145a7fc671c705d045d89b49922a758b5. eda96eddcbdda9632166232b2363c7b84da0994d. 5ec54d1e843729cd1e38a2f791f001226a653e95. 1e45d3f2239333217d3252f78151f4294fda4e80. a50f61f8fa903117a6df82d164628de310f16ae9. Test: treehugger Test: atest -c CtsSeccompHostTestCases:android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls Change-Id: Ic2b1f489ac9f1fec7d7a33c845c29891f4306bbd
* Revert "libdebuggerd: add protobuf implementation."Jerome Gaillard2021-01-261-10/+9
| | | | | | | | | | | | | | | | | | Revert "Let crash_dump read /proc/$PID." Revert submission 1556807-tombstone_proto Reason for revert: b/178455196, Broken test: android.seccomp.cts.SeccompHostJUnit4DeviceTest#testAppZygoteSyscalls on git_master on cf_x86_64_phone-userdebug Reverted Changes: Ide6811297:tombstoned: switch from goto to RAII. I8d285c4b4:tombstoned: make it easier to add more types of ou... Id0f0fa285:tombstoned: support for protobuf fds. I6be6082ab:Let crash_dump read /proc/$PID. Id812ca390:Make protobuf vendor_ramdisk_available. Ieeece6e6d:libdebuggerd: add protobuf implementation. Change-Id: Ia0a1ee57e7630e01c495dc166218f665340aad7f
* libdebuggerd: add protobuf implementation.Josh Gao2021-01-211-9/+10
| | | | | | | | | | | | | | This commit implements protobuf output for tombstones, along with a translator that should emit bytewise identical output to the existing tombstone dumping code, except for ancillary data from GWP-ASan and Scudo, which haven't been implemented yet. Test: setprop debug.debuggerd.translate.translate_proto_to_text 1 && /data/nativetest64/debuggerd_test/debuggerd_test Test: for TOMBSTONE in /data/tombstones/tombstone_??; do pbtombstone $TOMBSTONE.pb | diff $TOMBSTONE - done Change-Id: Ieeece6e6d1c26eb608b00ec24e2e725e161c8c92
* Merge "Improve error message in debuggerd fallback handler."Treehugger Robot2020-10-011-0/+2
|\
| * Improve error message in debuggerd fallback handler.Josh Gao2020-09-251-0/+2
| | | | | | | | | | | | Bug: http://b/164014625 Test: none Change-Id: I4f1e61be93c511676e66b909a15735bba963eff0
* | Add arch member into Unwinder object.Christopher Ferris2020-09-241-7/+3
|/ | | | | | | | | | | | | | | This simplifies some of the logic and removes the need to pass an Arch value to functions that should already know about the arch it is operating on. Includes fixes for debuggerd/libbacktrace. Added new unit tests to cover new cases. Test: All unit tests pass. Test: Faked unwinder failing to verify debuggerd error messages display Test: properly in backtrace and tombstone. Change-Id: I439fcae0695befcfb1cb4c0a786cc74949d33425
* debuggerd: switch to using platform headers for DEBUGGER_SIGNAL.Josh Gao2019-12-171-2/+3
| | | | | Test: treehugger Change-Id: Ie9736c4a077dba1029d2352bd94d47ce07323aec
* Revert "Check for data races when reading JIT/DEX entries."David Srbecky2019-04-051-3/+4
| | | | | | | | This reverts commit 85b5fecec920208ec43b42488f08d4c2e5aaeda2. Reason for revert: Breaks ART tests, reverting to investigate. Change-Id: I1bb905407e87cbd4f832646651133a9caf6fcfc8
* Check for data races when reading JIT/DEX entries.David Srbecky2019-03-291-4/+3
| | | | | | | | | | | Update the entries only when the list is modified by the runtime. Check that the list wasn't concurrently modified when being read. Bug: 124287208 Test: libunwindstack_test Test: art/test.py -b --host -r -t 137-cfi Change-Id: I87ba70322053a01b3d5be1fdf6310e1dc21bb084
* Replace libbacktrace with libunwindstack directly.Christopher Ferris2019-01-291-6/+13
| | | | | | | | | | Small modifications to the dump_stack method and added unit tests to verify the output. Bug: 120606663 Test: Unit tests pass, debuggerd run on processes on target. Change-Id: Id385a915b751abda3dd6baebed6c3ce498c3bf6e
* debuggerd_fallback: fix fd leak.Josh Gao2018-10-301-2/+3
| | | | | | | | | | Previously, when we received simultaneous dump requests, we were CASing a file descriptor value into a variable, and then failing to close it if the CAS failed. Bug: http://b/118412443 Test: debuggerd_test Change-Id: I075c35a239426002eb9416da3d268c3d1a18e9d2
* Fix multithreaded backtraces for seccomp processes.Josh Gao2018-09-121-3/+4
| | | | | | | | | | | Add threads to the existing seccomp backtrace test to prevent regressing this. Bug: http://b/114139908 Bug: http://b/115349586 Test: debuggerd_test32 Test: debuggerd_test64 Change-Id: I07fbe1619b60f0008deb045a249f9045404478c2
* debuggerd: fix CrasherTest.seccomp_crash_oom.Josh Gao2018-05-161-1/+10
| | | | | | | | | | Switch from _exit to raising SIGABRT when we recurse in the fallback handler, so that waiters see an abort instead of a regular exit. Bug: http://b/79717060 Test: debuggerd_test32 Test: debuggerd_test64 Change-Id: Iddee1cb1b759690adf07bbb8cd0fda2faac87571
* debuggerd_fallback: don't recursively abort.Josh Gao2018-02-221-6/+10
| | | | | | | | | | | | Calls to abort() will always result in our signal handler being called, because abort will manually unblock SIGABRT before raising it. This can lead to deadlock when handling address space exhaustion in the fallback handler. To fix this, switch our mutex to a recursive mutex, and manually keep track of our lock count. Bug: http://b/72929749 Test: debuggerd_test --gtest_filter="CrasherTest.seccomp_crash_oom" Change-Id: I609f263ce93550350b17757189326b627129d4a7
* debuggerd_fallback: fix race.Josh Gao2018-02-091-16/+89
| | | | | | | | | | | | | | | | | | | | | A race condition occurs when one thread takes more than a second to get scheduled to handle the signal we send to ask it to dump its stack. When this happens, the main thread will continue on, close the fd, and then ask the next thread to dump, but the slow thread will then wake up and try to write to the new thread's fd, or trigger an assertion in __linker_enable_fallback_allocator. Do a few things to make this less bad: - encode both target tid and fd in the shared atomic, so that we know who each fd is for - switch __linker_enable_fallback_allocator to return success instead of aborting, and bail out if it's already in use - write to the output fd right when we get to it, instead of doing it whenever the dumping code decides to, to reduce the likelihood that the timeout expires Test: debuggerd_test Change-Id: Ife0f6dae388b601e7f991605f14d7a0274013f6b
* crash_dump: fork a copy of the target's address space.Josh Gao2017-12-151-38/+58
| | | | | | | | | | | | | | Reduce the amount of time that a process remains paused by pausing its threads, fetching their registers, and then performing unwinding on a copy of its address space. This also works around a kernel change that's in 4.9 that prevents ptrace from reading memory of processes that we don't have immediate permissions to ptrace (even if we previously ptraced them). Bug: http://b/62112103 Bug: http://b/63989615 Test: treehugger Change-Id: I7b9cc5dd8f54a354bc61f1bda0d2b7a8a55733c4
* libdebuggerd: cleanup.Josh Gao2017-08-291-2/+2
| | | | | | | | | Move libdebuggerd headers into their own directory for namespacing, move some includes to the top of their implementing files, delete some dead code. Test: mma, treehugger Change-Id: Ie4c44e32e2ab3bc678092899d257fd4ed634aa34
* tombstoned: allow intercepts for java traces.Narayan Kamath2017-05-311-2/+3
| | | | | | | | | | | | | | | | | All intercept requests and crash dump requests must now specify a dump_type, which can be one of kDebuggerdNativeBacktrace, kDebuggerdTombstone or kDebuggerdJavaBacktrace. Each process can have only one outstanding intercept registered at a time. There's only one non-trivial change in this changeset; and that is to crash_dump. We now pass the type of dump via a command line argument instead of inferring it from the (resent) signal, this allows us to connect to tombstoned before we wait for the signal as the protocol requires. Test: debuggerd_test Change-Id: I189b215acfecd08ac52ab29117e3465da00e3a37
* tombstoned: Add a shared library version of libtombstoned_client...Narayan Kamath2017-05-221-2/+2
| | | | | | | | | | | | | | | | | | | .. for ART and the frameworks to link against. In the new stack dumping scheme (see related bug), the Java runtime will communicate with tombstoned in order to obtain a FD to which it can write its traces. Also move things around to separate headers that are private implementation details from headers that constitute the public debuggerd API. There are currently only three such headers : - tombstoned/tombstoned.h - debuggerd/client.h - debuggerd/handler.h Bug: 32064548 Test: make Change-Id: If1b8578550e373d84828b180bbe585f1088d1aa3
* Move libc_logging to libasync_safe.Christopher Ferris2017-05-021-8/+9
| | | | | | | | | | | | | | | | Move the name of the "private/libc_logging.h" header to <async_safe/log.h>. For use of libc_malloc_debug_backtrace, remove the libc_logging library. The library now includes the async safe log functions. Remove the references to libc_logging.cpp in liblog, it isn't needed because the code is already protected by a check of the __ANDROID__ define. Test: Compiled and boot bullhead device. Test: Run debuggerd unit tests. Test: Run liblog unit tests on target and host. Test: Run libmemunreachable unit tests (these tests are flaky though). Change-Id: Ie79d7274febc31f210b610a2c4da958b5304e402
* debuggerd_handler: implement missing fallback functionality.Josh Gao2017-03-091-13/+196
| | | | | | | | | Allow the fallback implementation to dump traces and create tombstones in seccomped processes. Bug: http://b/35858739 Test: debuggerd -b `pidof media.codec`; killall -ABRT media.codec Change-Id: I381b283de39a66d8900f1c320d32497d6f2b4ec4
* libdebuggerd_handler: in-process crash dumping for seccomped processes.Josh Gao2017-02-151-0/+48
Do an in-process unwind for processes that have PR_SET_NO_NEW_PRIVS enabled. Bug: http://b/34684590 Test: debuggerd_test, killall -ABRT media.codec Change-Id: I62562ec2c419d6643970100ab1cc0288982a1eed