Commit graph

679 commits

Author SHA1 Message Date
Elliott Hughes
f77f6f003c Remove various bits of dead code and unused workarounds.
Test: treehugger
Change-Id: I68fcd5da304d04ff4da3c3f3712fb79ce6b5791e
Merged-In: I68fcd5da304d04ff4da3c3f3712fb79ce6b5791e
2020-02-22 16:53:24 +00:00
Mitch Phillips
e0b4bb1b2e [GWP-ASan] Add GWP-ASan information to tombstones.
GWP-ASan can provide information about a crash that it caused. Grab the
GWP-ASan regions from the globals shared by the linker for crash-handler
purpopses, pull the information from GWP-ASan, and display it.

This adds two regions:
 1. Causality tracking by GWP-ASan. We now print a cause header about
 the crash, like `Cause: [GWP-ASan]: Use After Free on a 1-byte
 allocation at 0x7365bb3ff8`
 2. Allocation and deallocation stack traces.

Bug: 135634846
Test: atest debuggerd_test

Change-Id: Id28d5400c9a9a053fcde83a4788f971e677d4643
2020-02-18 16:49:50 -08:00
Ray Essick
bd3ba782f2 build crash_dump.policy files using Android.bp
use Android.bp instead of Android.mk to build and install the
crash_dump.policy files. This also allows mainline modules to pull
the files into their apex (dependency wasn't handled for Android.mk)

Bug: 147914640
Test: build, examine generated filesystem
Change-Id: Iae92d4f9d683ccfddf1716e7eb2877b7bff0c737
2020-02-03 08:57:46 -08:00
Elliott Hughes
f8c0350eaa Merge "debuggerd: remove the raw stack dump." 2020-01-23 16:07:42 +00:00
Elliott Hughes
627928e059 debuggerd: remove the raw stack dump.
This takes a lot of space, isn't convincingly useful, and makes it
likely that the far more valuable stuff that comes after it gets
truncated. So let's just drop it.

Bug: http://b/139860930
Test: manual crasher, presubmit
Change-Id: Ie417ffc07e3cb17e95fdb3d183f8c87de0f34b89
2020-01-22 14:13:46 -08:00
Josh Gao
55c7ed4e2e debuggerd_handler: increase thread stack size.
1 page isn't enough to log on AArch64, and clean pages are free, so
increase the stack size to 8 pages.

Bug: http://b/144887737
Test: treehugger
Change-Id: I731b3bc27ab37f4b830a9478a04cd34d4f7648d3
2020-01-17 17:25:30 -08:00
Steven Moreland
e40e4270e8 remove deprecated bp 'subdirs'
noticed some, so thought I would remove them everywhere here

Bug: N/A
Test: N/A
Change-Id: I2978673b158d6c253914ea22f7f0129e446a5f91
2020-01-14 12:18:40 -08:00
Josh Gao
a48b41bcb8 debuggerd: switch to using platform headers for DEBUGGER_SIGNAL.
Test: treehugger
Change-Id: Ie9736c4a077dba1029d2352bd94d47ce07323aec
2019-12-17 16:36:05 -08:00
Treehugger Robot
82a31b8749 Merge "Add variadic logging to libdebuggerd internal." 2019-11-19 19:04:55 +00:00
Mitch Phillips
aadebd8982 Add variadic logging to libdebuggerd internal.
GWP-ASan's crash information retrieval services requires a Printf()
function (declared by the system/implementing allocator). In this
instance, because _LOG is called with additional arguments (the log_t),
this function must be wrapped to conform to printf_t defined by
GWP-ASan.

We can easily wrap the variadic version.

Bug: 135634846
Test: atest debuggerd_test
Change-Id: I17209cd2b7455ce889e2f8194969f606cac329eb
2019-11-19 09:49:05 -08:00
Treehugger Robot
ba5351692e Merge "Include PSTATE in tombstones on arm64." 2019-11-19 14:07:37 +00:00
Peter Collingbourne
bb2f941f57 Include PSTATE in tombstones on arm64.
A thread's PSTATE can sometimes be critical for understanding a crash,
especially with MTE and other new features that store per-thread state
in PSTATE.

Bug: 135772972
Change-Id: I1bee25bffe7eea395f04b6449dc9227298cf866e
2019-11-18 17:57:37 -08:00
Tom Cherry
441054aa1e Remove old logger_entry_v* formats
logger_entry and logger_entry_v2 were used for the kernel logger,
which we have long since deprecated.  logger_entry_v3 is the same as
logger_entry_v4 without a uid field, so it is trivially removable,
especially since we're now always providing uids in log messages.

liblog and logd already get updated in sync with each other, so we
have no reason for backwards compatibility with their format.

Test: build, unit tests
Change-Id: I27c90609f28c8d826e5614fdb3fe59bde22b5042
2019-10-24 10:53:14 -07:00
Treehugger Robot
ecc9b1bd7f Merge "debuggerd_client_test: massively increase timeouts." 2019-10-17 21:33:46 +00:00
Josh Gao
f10d4a15d2 debuggerd_client_test: massively increase timeouts.
debuggerd_client.race seems to have suddenly started to flake, for no
apparent reason. This doesn't seem to reproduce locally, so increase
the timeouts to rule out our test VMs being slow.

Bug: http://b/142571257
Test: treehugger
Change-Id: Ic54a78b8da36cb1163cec7e7976c73c3da628a30
2019-10-17 12:09:49 -07:00
Nick Desaulniers
67d52aa0f6 [debuggerd] fix -Wreorder-init-list
C++20 wants members to be ordered unlike C99.

Bug: 139945549
Test: mm
Change-Id: I3cbca589511c1e0bbc10c691949e18de77e16031
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-10-10 14:54:35 -07:00
Elliott Hughes
ec220cd877 debuggerd: increase the default limit on tombstones to 32.
We're missing useful crashes, especially on hwasan builds.

Bug: http://b/140580637
Test: run crasher
Change-Id: Ib5d8d3bd3fc4d7fec77d0b10302e5595f97a3515
2019-09-26 14:36:01 -07:00
Christopher Ferris
11555f0961 Increase timeouts.
There is still some flakiness, so increase the timeout values.
Also remove the TEMP_FAILURE_RETRY macro usage in TIMEOUT calls.
That macro disables the ability of the alarm code to interrupt
the system call.

Bug: 141045754

Test: Unit tests pass.
Change-Id: Ia3c95dccc3076a3fd5ef6432097a57e4ccee4df3
2019-09-20 15:07:03 -07:00
Christopher Ferris
172b0a0834 Add TEMP_FAILURE_RETRY where appropriate.
Bug: 141045754

Test: Ran unit tests in a loop on walleye and cuttlefish.
Change-Id: I87b912e76889ed207ab17b862e4786ee44a382ba
2019-09-18 19:05:25 -07:00
Christopher Ferris
ab60668ef4 Allow getrlimit/ugetrlimit syscalls in tests.
The fdsan code uses getrlimit/ugetrlimit so need to allow that when
running the debuggerd unit tests.

Bug: 141045754

Test: Ran the offending tests hundreds of times without failure.
Change-Id: Iece94f03e7895d61ca8a8f3ab17dce7e54ddf9cd
2019-09-17 15:31:47 -07:00
Josh Gao
6cad139bcc Mark some tests as requiring root.
Bug: http://b/140123924
Test: mma
Change-Id: I3ad277179018631c50d9295cdb173dd9dfa7ac59
2019-08-27 16:09:32 -07:00
Josh Gao
8ad965ae5e tombstoned: start immediately after /data is mounted.
Catch as many early-boot crashes as we can by starting tombstoned
immediately after /data is mounted.

Bug: http://b/139864948
Test: adb shell su 0 dmesg | grep "starting service"
Change-Id: I7f8821102191a445e87020f3efa59a2e0620d9db
2019-08-22 15:19:44 -07:00
Treehugger Robot
44e343837f Merge "Add wchan data to ANR dump" 2019-07-20 16:40:54 +00:00
Kalesh Singh
1489e27bda Add wchan data to ANR dump
Since only privileged processes with CAP_SYS_ADMIN can read kernel
stack traces from /proc/*/stack, we dump the waiting channels
instead to provide some insight as to where the process might
be stuck in the kernel.

Bug: 135458700
Fixes: 135458700
Test: adb shell am hang; Check /data/anr/<anr-file> for
      wchan data.
Change-Id: I9f13511ad89a259ce5e5465155db15d45d2c46d8
2019-07-18 16:02:57 -07:00
Christopher Ferris
481e8379d3 Add cause message when stack overflow is detected.
Test: Ran new unit tests.
Test: Ran crasher stack-overflow, crasher64 stack-overflow and verified
Test: stack overflow cause is shown.
Test: Ran stack overflow app and verified tombstone includes stack-overflow
Test: message.
Change-Id: I9bb01186dff5ed81c77d84b6aaedb5332ddd7256
2019-07-17 14:14:26 -07:00
Christopher Ferris
afc0ff7fe0 Increase timeout to avoid flaky tests.
Also, print extra information when an error occurs.

Test: Ran unit tests.
Change-Id: I3404549db0ac18a4a82a99b2620556db96376bca
2019-06-26 15:08:51 -07:00
Josh Gao
5df504c5f8 crash_dump: populate uid field.
Bug: http://b/132359035
Test: manual
Change-Id: I99d8446024fc2d9395132dea45f03317976a9b62
2019-05-09 12:49:57 -07:00
Misha Wagner
39c5b8c21c Add UID printing to tombstone headers
This is for Android Telemetry to be able to categorise the processes
that produce tombstones.

Test: atest debugerd_test:TombstoneTest

Change-Id: Ie635347c9839eb58bfd27739050bd68cbdbf98da
2019-04-23 09:53:07 +01:00
Christopher Ferris
4ae266ccbd Add indicator that an elf is memory backed.
Modify the unwinder library to indicate that at least one of the stack
frames contains an elf file that is unreadable.

Modify debuggerd to display a note about the unreadable frame and a possible
way to fix it.

Bug: 129769339

Test: New unit tests pass.
Test: Ran an app that crashes and has an unreadable file and verified the
Test: message is displayed. Then setenforce 0 and verify the message is
Test: not displayed.
Change-Id: Ibc4fe1d117e9b5840290454e90914ddc698d3cc2
2019-04-18 15:37:52 -07:00
Treehugger Robot
371180bb72 Merge "debuggerd: call setsid in our children." 2019-04-16 23:29:04 +00:00
Josh Gao
18cb681247 debuggerd: call setsid in our children.
There appears to be a kernel bug that causes SIGHUP and SIGCONT to be
sent to the parent process group we spawn from if the process group
contains stopped jobs (e.g. the parent itself, because of wait_for_gdb).

Call setsid in all of our children to prevent this from happening.

Bug: http://b/31124563
Test: adb shell 'setprop debug.debuggerd.wait_for_gdb 1; killall -ABRT surfaceflinger'
Change-Id: I1a48d70886880a5bfbe2deb80d48deece55faf09
2019-04-16 13:17:08 -07:00
Treehugger Robot
e1d4648f46 Merge "crasher: add execute-only memory ("xom")." 2019-04-16 12:28:25 +00:00
Elliott Hughes
dd04c658c3 crasher: add execute-only memory ("xom").
Test: `crasher thread-xom`
Change-Id: Ia121848df966040968370e1e9cb840034d780e4f
2019-04-15 13:03:48 -07:00
Christopher Ferris
3336c7bce0 Remove include of backtrace/Backtrace.h.
Somehow the code was still including this include from libbacktrace.
I think the libbacktrace include directory was coming from some
transitive includes. I verified that nothing in debuggerd is using
the libbacktace.so shared library.

Bug: 120606663

Test: Builds, unit tests pass.
Change-Id: I85c2837c5a539ccefc5a7140949988058d21697a
2019-04-08 17:18:24 -07:00
David Srbecky
b9cc4fbb26 Revert "Check for data races when reading JIT/DEX entries."
This reverts commit 85b5fecec9.

Reason for revert: Breaks ART tests, reverting to investigate.

Change-Id: I1bb905407e87cbd4f832646651133a9caf6fcfc8
2019-04-05 18:23:32 +00:00
David Srbecky
85b5fecec9 Check for data races when reading JIT/DEX entries.
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
2019-03-29 14:01:32 +00:00
Christopher Ferris
7813345faa Add BuildId to frame information.
Update debuggerd to print BuildId information by default.

Bug: 120975492

Test: New unit tests pass.
Test: debuggerd -b <PID> shows build id information.
Test: tombstones include build id information.
Change-Id: I019b031113d0b77385516223c63455b868924440
2019-03-26 08:04:40 -07:00
Josh Gao
5e8d68c2b2 debuggerd_handler: demote abort on exec failure to log.
If a process is ptraced already, we might not be able to exec crash_dump
due to selinux. Since we can be called for non-fatal events, we
shouldn't abort in that case.

Bug: http://b/128054996
Test: treehugger
Change-Id: I1442041caa7af908df2ab87b9e010c44082e7587
2019-03-18 14:39:47 -07:00
Florian Mayer
3d67d347f5 Fix copy / move behaviour of Maps object.
Currently, moving or copying a Maps object leads to double free of MapInfo.

Even moving a Maps object  did not prevent this, as after a move
the object only has to be in an "unspecified but valid state", which can
be the original state for a vector of raw pointers (but not for a vector
of unique_ptrs).

Changing to unique_ptrs is the most failsafe way to make sure we never
accidentally destruct MapInfo.

Test: atest libuwindstack_test
      Failed LocalUnwinderTest#unwind_after_dlopen which also fails at master.

Change-Id: Id1c9739b334da5c1ba532fd55366e115940a66d3
2019-03-05 13:05:36 +00:00
Martin Stjernholm
852b64e549 Fix libdexfile dependencies to avoid direct dependency on libdexfile_external.
It should be dlopen'ed lazily by libdexfile_support now.

Also change debuggerd_test to not link libunwindstack and its dependencies
statically - the static libs can overlap with the dynamic ones.

Test: mmma system/core/debuggerd/
Test: atest debuggerd_test
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests (cannot get atest to work)
Bug: 124827589
Bug: 123186083
Change-Id: I9e7bf9bcbae499af4e1be4c9854bce441e2a7b55
2019-02-24 22:04:11 +00:00
Josh Gao
8954d0bc98 Merge changes from topic "base_cmsg"
* changes:
  adb: switch to base::{Send,Receive}FileDescriptors.
  debuggerd: switch to base::{Send,Receive}FileDescriptors.
  base: add helpers for sending/receiving file descriptors.
2019-02-19 20:53:01 +00:00
Josh Gao
5f87bbdb0a debuggerd: switch to base::{Send,Receive}FileDescriptors.
Bug: http://b/12204763
Test: debuggerd_test
Change-Id: I0be40916214de51ab36fd6bd6d44090a84312e51
2019-02-13 13:21:54 -08:00
Martin Stjernholm
e31cfb609d Use new static target for libdexfile_support.
This is necessary since the dynamic one is now using dlopen(), which isn't
available in static builds.

Test: m
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests (cannot get atest to work)
Bug: 123403798
Bug: 123186083
Change-Id: I06a9cdfe7e7cc01427ffd54b66c8ebab88782260
2019-02-12 22:03:48 +00:00
Christopher Ferris
60eb19795b Replace libbacktrace with libunwindstack directly.
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
2019-01-29 17:57:14 -08:00
Greg Kaiser
3fa9a59ea3 debuggerd: Fix return type in error case
With our method returning 'bool', a "return -1" is interpretted
as 'true'.  We change this to an explicit 'false', as desired.

Test: TreeHugger
Change-Id: I222858b797bc4242a2dc6d4fe81df3d2586d055a
2019-01-08 06:29:22 -08:00
Josh Gao
4175cee3cc debuggerd_client: resolve tid to tgid when dumping Java stacks.
Bug: http://b/121438213
Test: debuggerd_test32
Test: debuggerd_test64
Change-Id: I4d114c8b0c4586ba64de5b45b47b0ec5c10354f8
2019-01-04 13:57:09 -08:00
Martin Stjernholm
bb4f2b440a Revert^2 "Use libdexfile external API in libunwindstack."
This reverts commit cacf5bf6bc.

Reason for revert: Re-apply with proper fix for VNDK visibility on marlin and sailfish.

Test: Manual repro of http://b/121110092#comment1 on reported branch
Test: atest CtsRenderscriptTestCases
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Test: Forrest cts/art/gce-all: https://android-build.googleplex.com/builds/forrest/run/L00300000240828791
Test: Forrest cts/bionic/gce-all: https://android-build.googleplex.com/builds/forrest/run/L05600000240682947 (shows 27/2958 failed, but it doesn't pass on Blackbox either: http://screen/xbjioEf6UgR)
Test: Forrest cts/renderscript/gce-all: https://android-build.googleplex.com/builds/forrest/run/L66200000240680523
Bug: 119632407
Change-Id: I601aa97eac8127e30d753405f8bc1fc4ae7f849f
2018-12-19 21:04:35 +00:00
Martin Stjernholm
cacf5bf6bc Revert "Use libdexfile external API in libunwindstack."
This reverts commit 444e23d2fc.

The rest of the topic doesn't need to be reverted.

Reason for revert: Breaks renderscript on marlin and sailfish.

Test: Manual repro of http://b/121110092#comment1 on reported branch
Test: "atest CtsRenderscriptTestCases" on that branch
Test: mmma system/core/{libunwindstack,libbacktrace}, run host gtests
Test: Make image, flash, and reboot device.
Bug: 121110092, 119632407
Change-Id: If1976b19ce386c95bc5bd4fd6d523745c167de18
2018-12-19 00:11:04 +00:00
Josh Gao
ac64da1637 Merge "libdebuggerd: add timestamp to tombstones." 2018-12-15 00:12:24 +00:00
Josh Gao
6f4644d15b libdebuggerd: add timestamp to tombstones.
Bug: http://b/120099273
Test: debuggerd_test
Change-Id: I457506f8d9920d969e1eba0265f85693b484f1a9
2018-12-14 13:29:52 -08:00