[all-commits] [llvm/llvm-project] a31533: [libunwind] Handle G in personality string

Florian Mayer via All-commits all-commits at lists.llvm.org
Wed Sep 21 14:13:50 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a3153381af48b2e704750255a704748a13c4c4de
      https://github.com/llvm/llvm-project/commit/a3153381af48b2e704750255a704748a13c4c4de
  Author: Florian Mayer <fmayer at google.com>
  Date:   2022-09-21 (Wed, 21 Sep 2022)

  Changed paths:
    M libunwind/src/DwarfInstructions.hpp
    M libunwind/src/DwarfParser.hpp
    M libunwind/src/UnwindCursor.hpp
    M libunwind/src/UnwindLevel1.c
    M libunwind/src/libunwind.cpp

  Log Message:
  -----------
  [libunwind] Handle G in personality string

Tested with the following program:

```
static volatile int* x = nullptr;

void throws()  __attribute__((noinline)) {
  if (getpid() == 0)
    return;
  throw "error";
}

void maybe_throws()  __attribute__((noinline)) {
  volatile int y = 1;
  x = &y;
  throws();
  y = 2;
}

int main(int argc, char** argv) {
  int y;
  try {
    maybe_throws();
  } catch (const char* e) {
    //printf("Caught\n");
  }
  y = *x;
  printf("%d\n", y); // should be MTE failure.
  return 0;
}
```

Built using `clang++ -c -O2 -target aarch64-linux -fexceptions -march=armv8-a+memtag -fsanitize=memtag-heap,memtag-stack`

Currently only Android implements runtime support for MTE stack tagging.

Without this change, we crash on `__cxa_get_globals` when trying to catch
the exception (because the stack frame __cxa_get_globals frame will fail due
to tags left behind on the stack). With this change, we crash on the `y = *x;`
as expected, because the stack frame has been untagged, but the pointer hasn't.

Reviewed By: #libunwind, compnerd, MaskRay

Differential Revision: https://reviews.llvm.org/D128998




More information about the All-commits mailing list