File tree Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Expand file tree Collapse file tree 3 files changed +58
-1
lines changed Original file line number Diff line number Diff line change @@ -261,7 +261,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
261
261
cur_idx < 100 ? cur_idx : 100 , " " , cur_idx);
262
262
return nullptr ;
263
263
}
264
- if (abi && !abi->CodeAddressIsValid (cursor_sp->start_pc )) {
264
+
265
+ // Invalid code addresses should not appear on the stack *unless* we're
266
+ // directly below a trap handler frame (in this case, the invalid address is
267
+ // likely the cause of the trap).
268
+ if (abi && !abi->CodeAddressIsValid (cursor_sp->start_pc ) &&
269
+ !prev_frame->reg_ctx_lldb_sp ->IsTrapHandlerFrame ()) {
265
270
// If the RegisterContextUnwind has a fallback UnwindPlan, it will switch to
266
271
// that and return true. Subsequent calls to TryFallbackUnwindPlan() will
267
272
// return false.
Original file line number Diff line number Diff line change
1
+ #include <signal.h>
2
+ #include <stdint.h>
3
+ #include <unistd.h>
4
+
5
+ void sigbus_handler (int signo ) { _exit (47 ); }
6
+
7
+ int target_function () { return 47 ; }
8
+
9
+ int main () {
10
+ signal (SIGBUS , sigbus_handler );
11
+
12
+ // Generate a SIGBUS by deliverately calling through an unaligned function
13
+ // pointer.
14
+ union {
15
+ int (* t )();
16
+ uintptr_t p ;
17
+ } u ;
18
+ u .t = target_function ;
19
+ u .p |= 1 ;
20
+ return u .t ();
21
+ }
Original file line number Diff line number Diff line change
1
+ # REQUIRES: (target-aarch64 || target-arm) && native
2
+ # UNSUPPORTED: system-windows
3
+ # llvm.org/pr91610, rdar://128031075
4
+ # XFAIL: system-darwin
5
+
6
+ # RUN: %clang_host %S/Inputs/unaligned-pc-sigbus.c -o %t
7
+ # RUN: %lldb -s %s -o exit %t | FileCheck %s
8
+
9
+ # Convert EXC_BAD_ACCESS into SIGBUS on darwin.
10
+ settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_ACCESS
11
+
12
+ breakpoint set -n sigbus_handler
13
+ # CHECK: Breakpoint 1: where = {{.*}}`sigbus_handler
14
+
15
+ run
16
+ # CHECK: thread #1, {{.*}} stop reason = signal SIGBUS
17
+
18
+ thread backtrace
19
+ # CHECK: (lldb) thread backtrace
20
+ # CHECK: frame #0: [[TARGET:0x[0-9a-fA-F]*]] {{.*}}`target_function
21
+
22
+ continue
23
+ # CHECK: thread #1, {{.*}} stop reason = breakpoint 1
24
+
25
+
26
+ thread backtrace
27
+ # CHECK: (lldb) thread backtrace
28
+ # CHECK: frame #0: {{.*}}`sigbus_handler
29
+ # Unknown number of signal trampoline frames
30
+ # CHECK: frame #{{[0-9]+}}: [[TARGET]] {{.*}}`target_function
31
+
You can’t perform that action at this time.
0 commit comments