[libunwind] [libunwind][PAC] Defang ptrauth's PC in valid CFI range abort (PR #184041)

Anatoly Trosinenko via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 3 12:18:14 PST 2026


atrosinenko wrote:

> ... (rather than requiring a jit generated frame)

IIUC it should be rather straightforward to get a stack frame without any associated CFI by manually writing a function in assembly and not providing any `.cfi_*` directives for it.

```c
class my_exception {
  int n;
};

asm(
  "  .globl  caller\n"
  "  .p2align 4\n"
  "  .type   caller, at function\n"
  "caller:\n"
  "  stp     x29, x30, [sp, #-16]!\n"
  "  mov     x29, sp\n"
  "  bl      thrower\n"
  "  ldp     x29, x30, [sp], #16\n"
  "  ret\n"
);

extern "C" void caller();

extern "C" void thrower() {
  throw my_exception();
}

int main() {
  try {
    caller();
  } catch (...) {
    return 1;
  }
  return 0;
}
```

Though, I cannot make an assertion in `__unw_set_reg` trigger, I simply get "normal" abnormal termination instead:
```
libc++abi: terminating due to uncaught exception of type my_exception
```

I guess the `__unw_set_reg` function is only called during the Unwinding Phase, but it is not even started, as (I guess) missing debug info is already detected during the Search Phase. What I see in debugger is that if I set breakpoints at `unwind_phase1` and `unwind_phase2`, then I get the fatal error after I continue execution at `unwind_phase1` (without ever hitting `unwind_phase2`).

I guess that the issue may be reproduced by performing forced unwind, as IIRC it skips the first phase at all.

https://github.com/llvm/llvm-project/pull/184041


More information about the cfe-commits mailing list