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

Commit e22701ee authored by Josh Gao's avatar Josh Gao
Browse files

libbacktrace: remove exit time destructors.

If libbacktrace is statically linked into a library that interposes
libc, exit-time destructors can lead to a segfault upon exit if static
variables are used after their destruction.

Remove the one use of a static variable (with inconsequential
performance impact of less than 1us per backtrace), and enable
-Wexit-time-destructors to ensure this stays fixed in the future.

Test: mma
Change-Id: Icdaf1cf1c1f166cf501d9ecd1983c44e4305f7e9
parent b9670bb4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@ cc_library {
    defaults: ["libbacktrace_common"],
    host_supported: true,

    cflags: [
        "-Wexit-time-destructors",
    ],

    srcs: [
        "BacktraceMap.cpp",
    ],
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@

bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
                       std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames) {
  static std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"};
  std::vector<std::string> skip_names{"libunwindstack.so", "libbacktrace.so"};
  UnwindStackMap* stack_map = reinterpret_cast<UnwindStackMap*>(back_map);
  auto process_memory = stack_map->process_memory();
  unwindstack::Unwinder unwinder(MAX_BACKTRACE_FRAMES + num_ignore_frames, stack_map->stack_maps(),
+4 −0
Original line number Diff line number Diff line
@@ -65,6 +65,10 @@ cc_library {
        "Symbols.cpp",
    ],

    cflags: [
        "-Wexit-time-destructors",
    ],

    target: {
        // Always disable optimizations for host to make it easier to debug.
        host: {