-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[lldb/aarch64] Allow unaligned PC addresses below a trap handler #92093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <signal.h> | ||
#include <stdint.h> | ||
#include <unistd.h> | ||
|
||
void sigbus_handler(int signo) { _exit(47); } | ||
|
||
int target_function() { return 47; } | ||
|
||
int main() { | ||
signal(SIGBUS, sigbus_handler); | ||
|
||
// Generate a SIGBUS by deliverately calling through an unaligned function | ||
// pointer. | ||
union { | ||
int (*t)(); | ||
uintptr_t p; | ||
} u; | ||
u.t = target_function; | ||
u.p |= 1; | ||
return u.t(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# REQUIRES: (target-aarch64 || target-arm) && native | ||
# UNSUPPORTED: system-windows | ||
# llvm.org/pr91610, rdar://128031075 | ||
# XFAIL: system-darwin | ||
|
||
# RUN: %clang_host %S/Inputs/unaligned-pc-sigbus.c -o %t | ||
# RUN: %lldb -s %s -o exit %t | FileCheck %s | ||
|
||
# Convert EXC_BAD_ACCESS into SIGBUS on darwin. | ||
settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS | ||
|
||
breakpoint set -n sigbus_handler | ||
# CHECK: Breakpoint 1: where = {{.*}}`sigbus_handler | ||
|
||
run | ||
# CHECK: thread #1, {{.*}} stop reason = signal SIGBUS | ||
|
||
thread backtrace | ||
# CHECK: (lldb) thread backtrace | ||
# CHECK: frame #0: [[TARGET:0x[0-9a-fA-F]*]] {{.*}}`target_function | ||
|
||
continue | ||
# CHECK: thread #1, {{.*}} stop reason = breakpoint 1 | ||
|
||
|
||
thread backtrace | ||
# CHECK: (lldb) thread backtrace | ||
# CHECK: frame #0: {{.*}}`sigbus_handler | ||
# Unknown number of signal trampoline frames | ||
# CHECK: frame #{{[0-9]+}}: [[TARGET]] {{.*}}`target_function | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will currently not unwind past the |
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing I'll also need to forward some mach exception to make this work. Would that be EXC_BAD_ACCESS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes doing
b sigbus_handler; r
stops with an EXC_BAD_ACCESS without it being delivered to the process.b sigbus_handler; settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS; r
will stop when the SIGBUS is delivered.b sigbus_handler; settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS; process handle -p true -s false SIGBUS; r
will stop in sigbus_handler.On macOS we hit the same failure we saw in #91321 where we don't have eh_frame details for _sigtramp so this frameless leaf function that crashed is not discovered when we do the stack walk. This will need to be xfailed on macOS for the same reason as 91321. FWIW I filed a little work item on myself to figure out Something That Can Be Done in rdar://128031075 if you want to annotate the xfail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking this out. I'll xfail the test and reference the rdar, and also the llvm bug I created earlier.