[PATCH] D114385: [libunwind] Fix testing with sanitizers enabled

Louis Dionne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 29 14:02:09 PST 2021


ldionne added a comment.

In D114385#3159448 <https://reviews.llvm.org/D114385#3159448>, @leonardchan wrote:

>> The unwind_leaffunction.pass.cpp test was failing with ubsan because it was
>> relying on undefined behavior to "do the right thing" and result in a SIGSEGV.
>> IMO it makes more sense to simply raise a SIGSEGV directly, since that is guaranteed
>> to work.
>
> It looks like using `raise` causes this test to fail on our aarch64 builder <https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8829557385974689473/overview> with exit code 255 (from the `_Exit(-1)` in `signal_handler`). I'm unsure why it would fail when using `raise`. These are a couple of things I noticed when debugging:
>
> - If I replace `raise(SIGSEGV)` with `kill(getpid(), SIGSEGV)`, the test passes normally. The man page <https://man7.org/linux/man-pages/man3/raise.3.html> for raise says this is functionally equivalent.
> - If I manually print out the frame names from `info.dli_sname`, I notice with `raise` I only cover 2 frames (`_Z14signal_handleri`, `__kernel_rt_sigreturn`) but with `kill` I get 5 frames (`_Z14signal_handleri`, `__kernel_rt_sigreturn`, `kill`, `_Z18crashing_leaf_funcv`, `main`).
>   - If I use the old UB approach, I get 4 frames (just excluding the call to `kill`).
>
> Any ideas for why this might be the case?

No, that doesn't ring a bell. I think this is a question for whoever provides the C Standard Library on your aarch64 bot. Perhaps libunwind is somehow unable to understand the stack frames below `raise` before it gets to the kernel? Honestly I'm kind of shooting in the dark.

I'd be fine with switching to `kill(getpid(), SIGSEGV)` temporarily to unbreak your bot, but I'd like to avoid doing a blind fix and get the ball rolling on this issue with the C library folks. Do you think you can provide a patch to switch to `kill`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114385/new/

https://reviews.llvm.org/D114385



More information about the llvm-commits mailing list