Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a75e9b32 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8486043 from 27e71485 to tm-d1-release

Change-Id: If560f7cebb8ce403fb6d4d199c83a522597fe16a
parents 9b7a3f02 27e71485
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -113,8 +113,14 @@ constexpr char kWaitForDebuggerKey[] = "debug.debuggerd.wait_for_debugger";
// Enable GWP-ASan at the start of this process. GWP-ASan is enabled using
// process sampling, so we need to ensure we force GWP-ASan on.
__attribute__((constructor)) static void enable_gwp_asan() {
  bool force = true;
  android_mallopt(M_INITIALIZE_GWP_ASAN, &force, sizeof(force));
  android_mallopt_gwp_asan_options_t opts;
  // No, we're not an app, but let's turn ourselves on without sampling.
  // Technically, if someone's using the *.default_app sysprops, they'll adjust
  // our settings, but I don't think this will be common on a device that's
  // running debuggerd_tests.
  opts.desire = android_mallopt_gwp_asan_options_t::Action::TURN_ON_FOR_APP;
  opts.program_name = "";
  android_mallopt(M_INITIALIZE_GWP_ASAN, &opts, sizeof(android_mallopt_gwp_asan_options_t));
}

static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, unique_fd* output_fd,
+2 −3
Original line number Diff line number Diff line
@@ -73,14 +73,13 @@ static void debuggerd_fallback_trace(int output_fd, ucontext_t* ucontext) {
    thread.registers.reset(
        unwindstack::Regs::CreateFromUcontext(unwindstack::Regs::CurrentArch(), ucontext));

    // TODO: Create this once and store it in a global?
    unwindstack::UnwinderFromPid unwinder(kMaxFrames, getpid());
    // Do not use the thread cache here because it will call pthread_key_create
    // which doesn't work in linker code. See b/189803009.
    // Use a normal cached object because the process is stopped, and there
    // is no chance of data changing between reads.
    auto process_memory = unwindstack::Memory::CreateProcessMemoryCached(getpid());
    unwinder.SetProcessMemory(process_memory);
    // TODO: Create this once and store it in a global?
    unwindstack::UnwinderFromPid unwinder(kMaxFrames, getpid(), process_memory);
    dump_backtrace_thread(output_fd, &unwinder, thread);
  }
  __linker_disable_fallback_allocator();
+5 −2
Original line number Diff line number Diff line
@@ -43,10 +43,13 @@ static bool retrieve_gwp_asan_state(unwindstack::Memory* process_memory, uintptr
static const gwp_asan::AllocationMetadata* retrieve_gwp_asan_metadata(
    unwindstack::Memory* process_memory, const gwp_asan::AllocatorState& state,
    uintptr_t metadata_addr) {
  if (state.MaxSimultaneousAllocations > 1024) {
  // 1 million GWP-ASan slots would take 4.1GiB of space. Thankfully, copying
  // the metadata for that amount of slots is only 532MiB, and this really will
  // only be used with some ridiculous torture-tests.
  if (state.MaxSimultaneousAllocations > 1000000) {
    ALOGE(
        "Error when retrieving GWP-ASan metadata, MSA from state (%zu) "
        "exceeds maximum allowed (1024).",
        "exceeds maximum allowed (1,000,000).",
        state.MaxSimultaneousAllocations);
    return nullptr;
  }
+2 −2
Original line number Diff line number Diff line
@@ -101,10 +101,10 @@ void engrave_tombstone_ucontext(int tombstone_fd, int proto_fd, uint64_t abort_m
    }
  }

  unwindstack::UnwinderFromPid unwinder(kMaxFrames, pid, unwindstack::Regs::CurrentArch());
  auto process_memory =
      unwindstack::Memory::CreateProcessMemoryCached(getpid());
  unwinder.SetProcessMemory(process_memory);
  unwindstack::UnwinderFromPid unwinder(kMaxFrames, pid, unwindstack::Regs::CurrentArch(), nullptr,
                                        process_memory);
  if (!unwinder.Init()) {
    async_safe_format_log(ANDROID_LOG_ERROR, LOG_TAG, "failed to init unwinder object");
    return;
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <android-base/properties.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <liblp/builder.h>
@@ -31,6 +32,7 @@ using ::testing::AnyNumber;
using ::testing::ElementsAre;
using ::testing::NiceMock;
using ::testing::Return;
using android::base::GetProperty;

class Environment : public ::testing::Environment {
  public:
Loading