Commit graph

968 commits

Author SHA1 Message Date
Spandan Das
e010614a4a Merge "Make apex availability of libpropertyinfoparser and libpropertyinfoparser explicit" into main 2024-01-04 17:46:17 +00:00
Treehugger Robot
8880209aae Merge "Make apex availability of libdebuggerd explicit" into main 2024-01-04 02:49:43 +00:00
Spandan Das
2e5cfbc1a4 Make apex availability of libpropertyinfoparser and libpropertyinfoparser explicit
The availability to runtime apex was done implicitly using a baseline map in
build/soong/apex/apex.go. Make this explicit in Android.bp

Bug: 281077552
Test: m nothing
Change-Id: Iba1f30ef57c0707189ec79813ef501029135eeba
2024-01-04 01:34:40 +00:00
Christopher Ferris
20f50ec9ab Avoid sleep in test.
For the tombstoned.proto test, remove arbitrary sleep and add loop
checking for the file being present.

Bug: 317286869

Test: Ran the tests on device and all pass.
Test: Modify the test and force the timeout to verify the timeout logic.
Change-Id: I9b246c8fee83909459d5c42debdb546794070845
2024-01-03 04:32:35 +00:00
Spandan Das
e6bc0264a9 Make apex availability of libdebuggerd explicit
The availability to runtime apex was done implicitly using a baseline map in
build/soong/apex/apex.go. Make this explicit in Android.bp

Bug: 281077552
Test: m nothing
Change-Id: I365270bc90380211c40294dff145ebc01eb8c14f
2024-01-02 22:40:46 +00:00
Steven Moreland
2be4bedea1 raise debuggerd_test timeout
Possible solution for b/317286869.

Test: N/A
Change-Id: I93743d596d5b8d7c867253d1aafc709453995fed
2024-01-02 21:37:38 +00:00
Florian Mayer
cdf55585a7 Use correct stack depot size in __scudo_get_error
This is a no-op but will be used in upcoming scudo changes that allow to
change the depot size at process startup time, and as such we will no
longer be able to call __scudo_get_stack_depot_size in debuggerd.

Bug: 309446692
Change-Id: Ib64b9d042b2a2088484ec5e61944c089a1d85314
2023-12-13 22:21:19 +00:00
Treehugger Robot
1f5b0f9fee Merge "Handle scudo_stack_depot_size = 0" into main 2023-12-12 01:24:03 +00:00
Florian Mayer
f9566853bd Merge "Use scudo_stack_depot_size from process_info" into main 2023-12-11 23:38:13 +00:00
Siim Sammul
73ade16187 Merge "Move tombstone_proto_to_text out of libdebuggerd." into main 2023-12-06 10:13:18 +00:00
Treehugger Robot
1772cd427c Merge "Match upstream API change" into main 2023-12-06 01:28:10 +00:00
Florian Mayer
6757ecd2a3 Match upstream API change
Change was done in
e68c265543

Change-Id: Id1a288dfdb5edb7cb7d639ec4548926cc4085d8c
2023-12-06 00:16:43 +00:00
Siim Sammul
c08a34e3dc Move tombstone_proto_to_text out of libdebuggerd.
This is done so that we could depend on it elsewhere without needing all the unrelated methods.
Needed for ag/24553347

Bug: 296207744
Test: refactoring build
Change-Id: I7c6733208f3ae63ba9559753a24cffcb8e1b9d1e
2023-12-05 10:14:27 +00:00
Florian Mayer
4841207b53 Handle scudo_stack_depot_size = 0
Bug: 309446692
Change-Id: Ic55294316137847041f1e829cb0243aae8926379
2023-12-04 17:29:23 -08:00
Florian Mayer
e8fcfee409 Use scudo_stack_depot_size from process_info
This is a no-op but will be used in upcoming scudo changes that allow to
change the depot size at process startup time, and as such we will no
longer be able to call __scudo_get_stack_depot_size in debuggerd.

We already did the equivalent change for the ring buffer size in
https://r.android.com/q/topic:%22scudo_ring_buffer_size%22

Bug: 309446692
Change-Id: I761a7602c54a1f8f2d0575c5e011820d8dbaab63
2023-12-04 16:48:45 -08:00
Christopher Ferris
c7cc571fa1 Avoid crashing on bad architecture value.
The only way to get a bad architecture value in the protobuf is if
the data was corrupted or an unsupported architecture was added without
the register support.

If the protobuf is corrupted, this is strictly better since it
still produces a tombstone with the data present.

If there is an unsupported architecture, it will still result in a tombstone,
only the registers would not be present. It would also be very obviously
a problem that needs to be fixed. Again, this is strictly better since
the crash in generation is not necessarily visible unless you look at
the log. Here, the data is in the log and in the tombstone.

This also removes the only dependency in this file on the async_safe
library.

Test: Ran unit tests.
Test: Forced an invalid architecture and verified tombstone is present
Test: with error message, and error message printed in the log.
Change-Id: I8e4a2e3f778fafb5b7241c2f23d5f867f1341ed8
2023-11-17 22:12:14 +00:00
Christopher Ferris
1503890fc6 Update to support new shared_ptr returns.
Bug: 309857311

Test: All unit tests pass.
Change-Id: Ia44ebeb558d3d1101ab63b064731656f0f89c487
2023-11-10 00:05:49 -08:00
Mattias Simonsson
38ab045342 debuggerd_test: Scale timeouts by HwTimeoutMultiplier
Timeouts in tombstoned.cpp and intercept_manager.cpp are scaled
by HwTimeoutMultiplier, but the timeouts in debuggerd_test.cpp
are not, which means the CrasherTest#intercept_timeout test will
fail for any platform that has a high enough HwTimeoutMultiplier.

Bug: 309532789
Test: debuggerd_test.CrasherTest#intercept_timeout
Change-Id: I83cd01e87644c011efa155a32fd5d92cc8a43a95
2023-11-08 14:56:48 -08:00
Christopher Ferris
6aa72490dc Add new segv type SEGV_CPERR.
The new 6.6 kernel headers added a new segv type, SEGV_CPERR. Add this
to the switch statement.

Test: Unit tests pass.
Change-Id: I77eb4748e51c7e7d7291bfd2180b0ccb3b5a6ded
2023-10-31 14:01:09 -07:00
Christopher Ferris
b92b52c071 Add ability to handle multiple intercepts per pid.
While doing this, refactor the intercept code to be easier to understand.

The primary use case for this is to perform a parallel stack dump (both Java and native) for specific ANRs.

Add tests for all of the different intercept conditions.

Modify the tests to display the error message from the intercept
response if there is an error.

Bug: 254634348
Test: All unit tests pass.
Test: Ran debuggerd on native and java processes.
Test: Created a bugreport without error.
Change-Id: Ic531ccee05b9a470748b815cf109e0076150a0b6
2023-10-19 15:13:59 +00:00
Elliott Hughes
041afb2883 Add the missing copyright headers to the .S files.
Dates taken from `git log --follow`.

Test: treehugger
Change-Id: I80e9ea6aa01f8e0553295453749afcbc3af827f9
2023-09-28 10:41:21 -07:00
Christopher Ferris
f58b009b7b Disable warning which is not detecting problems.
A clang update enabled -Wreorder-init-list by default. Since it doesn't
provide any benefit to the debuggerd code, disable the warning.

Test: Builds without warnings.
Change-Id: I75cfe064ba92c74312ba33f329b1364258eba06c
2023-09-12 13:01:10 -07:00
Andrei Diea
e3bda36e0b debuggerd: add socksetopt to seccomp policy
aosp/2734054 added socket timeouts for nonblocking liblog ops.
seccomp policy was not updated so tests failed when unallowed
socksetopt syscall was made.

Bug: 298420226
Test: atest debuggerd_test

Change-Id: Iace232ec8b94e5d316d344abc5d866fe314607e0
Signed-off-by: Andrei Diea <adiea@google.com>
2023-09-05 19:29:13 +00:00
Christopher Ferris
9f32fba6d3 Merge "Fix potential miscellaneous debuggerd issues." into main 2023-08-10 19:53:19 +00:00
Christopher Ferris
3a0833c9cd Fix potential miscellaneous debuggerd issues.
Check for the log opening failing.

Add the ability to put error messages in the log and tombstone so
that it's clear if the log reading failed in some way.

Adjust test so that if there is a log or if no log exists, the test
will still pass.

Print an <unknown> if the command line is unreadable instead of nothing.

Test: Ran unit tests.
Test: Induced error and verified error message is save in tombstone.
Change-Id: I2fce8078573b40b9fed3cd453235f3824cadb5e3
2023-08-09 17:31:55 -07:00
Treehugger Robot
cf32fd18d4 Merge "debuggerd: fix passing of fdsan_table to crash_dump" into main 2023-08-09 23:15:06 +00:00
Tomislav Novak
24a7df5d38 debuggerd: fix passing of fdsan_table to crash_dump
Commit aosp/1259140 moved fdsan_table into debugger_process_info, which
is populated conditionally. This introduced a bug where the process that
receives BIONIC_SIGNAL_DEBUGGER (35) does not propagate the fdsan_table
pointer to crash_dump:

  $ adb shell kill -SIG35 <pid>
  $ adb logcat -s DEBUG
  E DEBUG   : failed to read fdsan table entry 0: I/O error

Fdsan in warn-only mode uses BIONIC_SIGNAL_DEBUGGER[1], so the generated
tombstones don't have any fd ownership info.

Fix it by calling get_process_info() irrespective of the signal being
handled, taking care to preserve the previous behavior of not showing
abort messages set by applications in non-fatal dumps.

Test: debuggerd_test
Test: send SIG35 to arbitrary process and inspect the log and tombstone
Test: crasher fdsan_file

[1] 20ad9129e7/libc/bionic/fdsan.cpp (166)

Change-Id: I76931ca4825e846fc99f26fa590c045130abb850
2023-08-09 15:19:51 -07:00
Treehugger Robot
8f5fab42df Merge "crasher: add pac and bti crashes." into main 2023-08-08 23:47:21 +00:00
Elliott Hughes
1b13b14758 crasher: add pac and bti crashes.
Also add the missing `.size` directives to all the assembler functions
for slightly improved backtraces.

Test: crasher64 pac; crasher64 bti
Change-Id: I8e0c127cbff56c33637e6ca8f1d927b971951807
2023-08-08 16:06:24 -07:00
Christopher Ferris
48d6e0452e Make libdebuggerd ramdisk available.
Test: Builds and debuggerd unit tests pass.
Change-Id: I2a5bd96e349f81ae0bec8dbffc49646c1f58bfea
2023-07-31 14:24:01 -07:00
Andrew Walbran
9fbd1683d4 Add safety comments.
These will soon be required by a lint.

Bug: 290018030
Test: m vm virtmgr
Change-Id: Id628b2a88f1cb0235fbccc748c52514e64561fe5
2023-07-10 14:56:20 +01:00
Kelvin Zhang
786dac3d50 Update some fs_mgr/debuggerd to use getpagesize() instead of PAGE_SIZE
Test: th
Bug: 279808236
Change-Id: I9d30cfe19d2b1a7d624cc5425e4315dc6e3b2ad2
2023-06-27 10:50:07 -07:00
Christopher Ferris
1442d47bd6 Merge "Check get_gwp_asan_callbacks before calling." 2023-05-26 19:03:01 +00:00
Christopher Ferris
004a16739d Check get_gwp_asan_callbacks before calling.
When using the bootstrap linker, the get_gwp_asan_callbacks is
not set. Therefore, check it is not nullptr before calling it
during crash processing.

Bug: 284098779

Test: Ran crasher64 using /system/bin/bootstrap/linker64 and verify
Test: debuggerd code does not crash.
Test: All unit tests pass.
Change-Id: Ifc710fe4bef24661700444a1b69432bfc29d580f
2023-05-25 12:42:41 -07:00
Treehugger Robot
2dc80e3805 Merge "Updated the policy file associated with riscv64" 2023-05-25 17:29:40 +00:00
liwentao
4d8f37edae Updated the policy file associated with riscv64
The generate.sh script can generate the file, but current policy file does not match it.
And the rules are not appropriate, like missing "sysinfo", causing the
debuggerd_test to fail in system model. So we match the policy to
what it should be.

Test: make debuggerd_test

Change-Id: I57ebd7713f2ab939d01bfefcc7935e234fdd3e13
Signed-off-by: liwentao <liwentao@eswincomputing.com>
2023-05-25 18:08:02 +08:00
Christopher Ferris
98d6242dc7 Limit the number of log messages in a tombstone.
Some testing environments can have a test that is sending many
thousands of messages to the log. When this type of process crashes
all of these log messages are captured and can cause OOM errors
while creating the tombstone.

Added a test to verify the log messages are truncated. Leaving this
test disabled for now since it is inherently flaky due to having to
assume that 500 messages are in the log.

Added a test for a newline in a log message since it's somewhat
related to this change.

NOTE: The total number of messages is capped at 500, but if a message
contains multiple newlines, the total messages will exceed 500.
Counting messages this way seems to be in the spirit of the cap,
that a process logging a large message with multiple newlines does
not completely fill the tombstone log data.

Bug: 269182937
Bug: 282661754

Test: All unit tests pass.
Test: The disabled max_log_messages test passes.
Change-Id: If18e62b29f899c2c4670101b402e37762bffbec6
2023-05-24 20:10:55 +00:00
Frederick Mayle
56abaa0959 debuggerd: simplify output handling
Just noticed some opportunities while skimming.

Test: adb shell debuggerd $(adb shell pidof com.android.systemui)
Test: All unit tests pass (both 32 bit and 64 bit).
Test: Ran unit tests in a loop hundreds of times.
Change-Id: I428d0cf599ed603a21944b084b95594db893cbd5
2023-05-19 15:19:06 -07:00
Frederick Mayle
52205b8206 debuggerd_client_test: less racy test setup
Make sure that all the threads have started up, otherwise the main part
of the test might not be testing as stressful a situation as expected.
Note that the "race" moniker is still valid because of the debuggerd
timeout.

The test is now faster (405ms) when run under good conditions.

Test: atest 'debuggerd_test:debuggerd_client#race'
Test: Ran debuggerd_client.race 1000 times on its own.
Test: Ran the whole suite of debuggerd unit tests 1000 times.
Change-Id: I487e7654a71df9f1799f09c6f385c929ddf2f234
2023-05-17 12:50:51 -07:00
Christopher Ferris
bda1064160 Re-add code to skip gettings logs on logd crashes.
Also add new unit tests to verify this behavior.

Bug: 276934420

Test: New unit tests pass.
Test: Ran new unit tests without pthread_setname_np call and verified
Test: the tests fail.
Test: Force crash logd and verify log messages are not gathered.
Test: Force crash a logd thread and verify log messages are not gathered.
Change-Id: If8effef68f629432923cdc89e57d28ef5b8b4ce2
2023-04-24 18:31:29 -07:00
Florian Mayer
152de539df Merge "Print number of frames" 2023-04-10 20:59:18 +00:00
Florian Mayer
59e632a292 Print number of frames
liblog can drop data when debuggerd is overloaded, which leads to
truncated tombstones. by adding the count separately, automation can
easily see whether it is dealing with a truncated tombstone or not.

Bug: 269537146
Change-Id: Ia991537efc0d6b57cbff23ee45af6521467aa20d
2023-04-06 23:38:40 +00:00
Kevin Jeon
2a70a7432c Merge "Add pointer dereference in debuggerd error msg" 2023-04-05 22:34:51 +00:00
Kevin Jeon
06af624e66 Add pointer dereference in debuggerd error msg
This change adds a missing pointer dereference to the InterceptResponse
when checking for a size mismatch.

Test: build
Bug: N/A
Change-Id: I88afed6f1c0f33fe237d337b0fb8fc0a0c0e3bac
2023-04-05 16:32:39 -04:00
Treehugger Robot
1c324d3559 Merge "Handle with the nonnull case in a tricky way" 2023-04-01 02:46:24 +00:00
zijunzhao
fa8037c207 Handle with the nonnull case in a tricky way
The func readdir() is not allowed to pass a nullptr.
Bug: b/245972273
Test: mm

Change-Id: Idbb3f552b026dc6d727886d22989d3359ed6633b
2023-03-31 23:50:37 +00:00
Mitch Phillips
5a2a302108 Merge "[debuggerd] New protocol to AM to handle recoverable crashes." 2023-03-29 20:28:35 +00:00
Elliott Hughes
3b1e71c63b Merge "riscv64: fix debuggerd_test build." 2023-03-21 18:56:36 +00:00
Shikha Panwar
e11ab73647 Merge "Add tombstone_handler for crashes in Microdroid" 2023-03-21 18:14:12 +00:00
Elliott Hughes
857e29c356 riscv64: fix debuggerd_test build.
This adds the missing assembler for riscv64, even though I don't have a
working tombstoned yet to test it with. There's a distinct possibility
we'll be back to fix the test (because although "register 1" is harmless
for the other architectures, it's the ra register on riscv64; the default
link register), but at least this lets us build the test.

I've also simplified all the assembly to be the simplest sequence I
know that writes 0 to address 0 (because if there was a reason to use
so many instructions before, I want to know what it is so I can write
the missing comment!).

Test: treehugger
Change-Id: I10d117eaedf361d9759a450e0973d07c4f97090e
2023-03-20 17:48:53 -07:00