diff --git a/support/ebpf/interpreter_dispatcher.ebpf.c b/support/ebpf/interpreter_dispatcher.ebpf.c index 8e9f6a26d..33aa52816 100644 --- a/support/ebpf/interpreter_dispatcher.ebpf.c +++ b/support/ebpf/interpreter_dispatcher.ebpf.c @@ -763,6 +763,7 @@ static EBPF_INLINE int unwind_stop(struct pt_regs *ctx) increment_metric(metricID_NumUnknownPC); } // Fallthrough to report the error + [[fallthrough]]; default: increment_metric(state->error_metric); } diff --git a/support/ebpf/native_stack_trace.ebpf.c b/support/ebpf/native_stack_trace.ebpf.c index 800e512cd..75356b1e4 100644 --- a/support/ebpf/native_stack_trace.ebpf.c +++ b/support/ebpf/native_stack_trace.ebpf.c @@ -137,16 +137,19 @@ static EBPF_INLINE void *get_stack_delta_map(int mapID) // Get the stack offset of the given instruction. static EBPF_INLINE ErrorCode get_stack_delta(UnwindState *state, int *addrDiff, u32 *unwindInfo) { + u64 text_section_offset = state->text_section_offset; + if (state->return_address) + --text_section_offset; u64 exe_id = state->text_section_id; // Look up the stack delta page information for this address. StackDeltaPageKey key = {}; key.fileID = state->text_section_id; - key.page = state->text_section_offset & ~STACK_DELTA_PAGE_MASK; + key.page = text_section_offset & ~STACK_DELTA_PAGE_MASK; DEBUG_PRINT( "Look up stack delta for %lx:%lx", (unsigned long)state->text_section_id, - (unsigned long)state->text_section_offset); + (unsigned long)text_section_offset); StackDeltaPageInfo *info = bpf_map_lookup_elem(&stack_delta_page_to_info, &key); if (!info) { DEBUG_PRINT( @@ -176,7 +179,7 @@ static EBPF_INLINE ErrorCode get_stack_delta(UnwindState *state, int *addrDiff, // Preinitialize the idx for the index to use for page without any deltas. u32 idx = info->firstDelta; - u16 page_offset = state->text_section_offset & STACK_DELTA_PAGE_MASK; + u16 page_offset = text_section_offset & STACK_DELTA_PAGE_MASK; if (info->numDeltas) { // Page has deltas, so find the correct one to use using binary search. u32 lo = info->firstDelta; diff --git a/support/ebpf/tracer.ebpf.amd64 b/support/ebpf/tracer.ebpf.amd64 index 016969cea..80a1ef173 100644 Binary files a/support/ebpf/tracer.ebpf.amd64 and b/support/ebpf/tracer.ebpf.amd64 differ diff --git a/support/ebpf/tracer.ebpf.arm64 b/support/ebpf/tracer.ebpf.arm64 index 61cf1e1de..f950d9ddb 100644 Binary files a/support/ebpf/tracer.ebpf.arm64 and b/support/ebpf/tracer.ebpf.arm64 differ diff --git a/tools/coredump/testdata/arm64/rust-debug-offbyone.json b/tools/coredump/testdata/arm64/rust-debug-offbyone.json new file mode 100644 index 000000000..c8be1b445 --- /dev/null +++ b/tools/coredump/testdata/arm64/rust-debug-offbyone.json @@ -0,0 +1,30 @@ +{ + "coredump-ref": "517028a6d45241ed202e81083d836a47469e68a1345d7be7860f8127b5823d90", + "threads": [ + { + "lwp": 3428, + "frames": [ + "test_rust+0x12f60", + "test_rust+0x12f83", + "test_rust+0x12fa7", + "test_rust+0x1317f", + "test_rust+0x1303f", + "test_rust+0x1312b", + "test_rust+0x2be73", + "test_rust+0x13103", + "test_rust+0x1301f", + "" + ] + } + ], + "modules": [ + { + "ref": "36d6ee161f7831c61ecad24a80fc26d8a7221db3907639c6f078d59bbadc2549", + "local-path": "/home/brennan/test_rust/target/debug/test_rust" + }, + { + "ref": "a5945db37288c7ccf89169b911fa7ac634e7d2434a0b8287e485cf5ea98d5646", + "local-path": "/gnu/store/50jqiigxwa1s9xljqrl1wh85yncqnybr-glibc-2.41/lib/ld-linux-aarch64.so.1" + } + ] +}