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

Commit a74aae80 authored by Christopher Ferris's avatar Christopher Ferris
Browse files

Move to the libc++ demangler.

The previous versions of the libc++ demangler crashed on bad input.
However, the new version passes a fuzzer and has a lot of tests. Since
it's more complete than the local demangler, use it instead.

Modified the expected output of an offline test since the new demangler
handles a case that didn't work before.

Verified that the time it takes for the check_for_leak tests did not
change after this.

Bug: 136138882

Test: Ran the unit tests.
Test: Verified the __cxa_demangle function passes the fuzzer when run for
Test: hours. Both the 32 bit and 64 bit version of __cxa_demangle were
Test: fuzzed using external/libcxxabi/fuzz.
Change-Id: I10c06b589d57c36d89dbecba020b1ef2da69634a
parent 97c06703
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -125,10 +125,6 @@ cc_library {
        },
    },

    whole_static_libs: [
        "libdemangle"
    ],

    static_libs: [
        "libprocinfo",
    ],
+11 −3
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@
#include <android-base/stringprintf.h>
#include <android-base/strings.h>

#include <demangle.h>

#include <unwindstack/Elf.h>
#include <unwindstack/JitDebug.h>
#include <unwindstack/MapInfo.h>
@@ -40,6 +38,9 @@
#include <unwindstack/DexFiles.h>
#endif

// Use the demangler from libc++.
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int* status);

namespace unwindstack {

// Inject extra 'virtual' frame that represents the dex pc data.
@@ -330,7 +331,14 @@ std::string Unwinder::FormatFrame(const FrameData& frame) {
  }

  if (!frame.function_name.empty()) {
    data += " (" + demangle(frame.function_name.c_str());
    char* demangled_name = __cxa_demangle(frame.function_name.c_str(), nullptr, nullptr, nullptr);
    if (demangled_name == nullptr) {
      data += " (" + frame.function_name;
    } else {
      data += " (";
      data += demangled_name;
      free(demangled_name);
    }
    if (frame.function_offset != 0) {
      data += android::base::StringPrintf("+%" PRId64, frame.function_offset);
    }
+8 −4
Original line number Diff line number Diff line
@@ -1482,11 +1482,15 @@ TEST_F(UnwindOfflineTest, load_bias_ro_rx_x86_64) {
      "  #09 pc 0000000000ed5e25  perfetto_unittests "
      "(testing::internal::UnitTestImpl::RunAllTests()+581)\n"
      "  #10 pc 0000000000ef63f3  perfetto_unittests "
      "(_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_"
      "MS4_FS3_vEPKc+131)\n"
      "(bool "
      "testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, "
      "bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char "
      "const*)+131)\n"
      "  #11 pc 0000000000ee2a21  perfetto_unittests "
      "(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_"
      "FS3_vEPKc+113)\n"
      "(bool "
      "testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, "
      "bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char "
      "const*)+113)\n"
      "  #12 pc 0000000000ed5bb9  perfetto_unittests (testing::UnitTest::Run()+185)\n"
      "  #13 pc 0000000000e900f0  perfetto_unittests (RUN_ALL_TESTS()+16)\n"
      "  #14 pc 0000000000e900d8  perfetto_unittests (main+56)\n"