diff --git a/nativeunwind/stackdeltatypes/stackdeltatypes.go b/nativeunwind/stackdeltatypes/stackdeltatypes.go index fd4f0ed11..334e9fa75 100644 --- a/nativeunwind/stackdeltatypes/stackdeltatypes.go +++ b/nativeunwind/stackdeltatypes/stackdeltatypes.go @@ -76,6 +76,15 @@ type IntervalData struct { func (deltas *StackDeltaArray) AddEx(delta StackDelta, sorted bool) { num := len(*deltas) if delta.Info.Flags&support.UnwindFlagCommand != 0 { + if delta.Info.Param == support.UnwindCommandSignal { + // EBPF code does a -1 fixup for return addresses. + // To match the signal handler function injected into + // stack, the signal handler stack delta must start one + // byte earlier to accommodate for the ebpf fixup. + // C-libraries will have a 'nop' inserted to make sure + // nothing conflicts. + delta.Address-- + } // FP information is invalid/unused for command opcodes. // But DWARF info often leaves bogus data there, so resetting it // reduces the number of unique Info contents generated. diff --git a/processmanager/execinfomanager/synthdeltas.go b/processmanager/execinfomanager/synthdeltas.go index 29b384bbb..ee26e6e10 100644 --- a/processmanager/execinfomanager/synthdeltas.go +++ b/processmanager/execinfomanager/synthdeltas.go @@ -48,7 +48,7 @@ func createVDSOSyntheticRecordArm64(ef *pfelf.File) sdtypes.IntervalData { if sym.Name == "__kernel_rt_sigreturn" { deltas = append( deltas, - sdtypes.StackDelta{Address: addr, Info: sdtypes.UnwindInfoSignal}, + sdtypes.StackDelta{Address: addr - 1, Info: sdtypes.UnwindInfoSignal}, sdtypes.StackDelta{Address: addr + sym.Size, Info: sdtypes.UnwindInfoLR}, ) return true diff --git a/processmanager/execinfomanager/synthdeltas_test.go b/processmanager/execinfomanager/synthdeltas_test.go index d16c65c1d..272498986 100644 --- a/processmanager/execinfomanager/synthdeltas_test.go +++ b/processmanager/execinfomanager/synthdeltas_test.go @@ -28,7 +28,7 @@ func TestVDSOArm64(t *testing.T) { {Address: 0x7e4, Info: sdtypes.UnwindInfoLR}, {Address: 0x800, Info: frameSize16}, {Address: 0x80c, Info: sdtypes.UnwindInfoLR}, - {Address: 0x8f8, Info: sdtypes.UnwindInfoSignal}, + {Address: 0x8f7, Info: sdtypes.UnwindInfoSignal}, {Address: 0x900, Info: sdtypes.UnwindInfoLR}, }, } diff --git a/support/ebpf/native_stack_trace.ebpf.c b/support/ebpf/native_stack_trace.ebpf.c index dde9ec8af..de870bc70 100644 --- a/support/ebpf/native_stack_trace.ebpf.c +++ b/support/ebpf/native_stack_trace.ebpf.c @@ -157,22 +157,17 @@ 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 exe_id = state->text_section_id; + unsigned long exe_id = state->text_section_id; + unsigned long offset = state->text_section_offset - (int)state->return_address; // 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; - DEBUG_PRINT( - "Look up stack delta for %lx:%lx", - (unsigned long)state->text_section_id, - (unsigned long)state->text_section_offset); + key.fileID = exe_id; + key.page = offset & ~STACK_DELTA_PAGE_MASK; + DEBUG_PRINT("Look up stack delta for %lx:%lx", exe_id, offset); StackDeltaPageInfo *info = bpf_map_lookup_elem(&stack_delta_page_to_info, &key); if (!info) { - DEBUG_PRINT( - "Failure to look up stack delta page fileID %lx, page %lx", - (unsigned long)key.fileID, - (unsigned long)key.page); + DEBUG_PRINT("Failure to look up stack delta page fileID %lx, page %lx", exe_id, offset); state->error_metric = metricID_UnwindNativeErrLookupTextSection; return ERR_NATIVE_LOOKUP_TEXT_SECTION; } @@ -180,23 +175,21 @@ static EBPF_INLINE ErrorCode get_stack_delta(UnwindState *state, int *addrDiff, void *outer_map = get_stack_delta_map(info->mapID); if (!outer_map) { DEBUG_PRINT( - "Failure to look up outer map for text section %lx in mapID %d", - (unsigned long)exe_id, - (int)info->mapID); + "Failure to look up outer map for text section %lx in mapID %d", exe_id, (int)info->mapID); state->error_metric = metricID_UnwindNativeErrLookupStackDeltaOuterMap; return ERR_NATIVE_LOOKUP_STACK_DELTA_OUTER_MAP; } void *inner_map = bpf_map_lookup_elem(outer_map, &exe_id); if (!inner_map) { - DEBUG_PRINT("Failure to look up inner map for text section %lx", (unsigned long)exe_id); + DEBUG_PRINT("Failure to look up inner map for text section %lx", exe_id); state->error_metric = metricID_UnwindNativeErrLookupStackDeltaInnerMap; return ERR_NATIVE_LOOKUP_STACK_DELTA_INNER_MAP; } // 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 = 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 cda39d181..13ebc461e 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 512510e3a..f9b4e1c7d 100644 Binary files a/support/ebpf/tracer.ebpf.arm64 and b/support/ebpf/tracer.ebpf.arm64 differ diff --git a/tools/coredump/testdata/amd64/dotnet10-alpine3.23.json b/tools/coredump/testdata/amd64/dotnet10-alpine3.23.json index c8e0f4105..03172a019 100644 --- a/tools/coredump/testdata/amd64/dotnet10-alpine3.23.json +++ b/tools/coredump/testdata/amd64/dotnet10-alpine3.23.json @@ -49,7 +49,7 @@ "ld-musl-x86_64.so.1+0x6799f", "ld-musl-x86_64.so.1+0x6731a", "ld-musl-x86_64.so.1+0x6757a", - "" + "ld-musl-x86_64.so.1+0x68ec0" ] }, { diff --git a/tools/coredump/testdata/arm64/java-17.ShaShenanigans.StubRoutines.sha256_implCompressMB.sha256h.json b/tools/coredump/testdata/arm64/java-17.ShaShenanigans.StubRoutines.sha256_implCompressMB.sha256h.json index 280f569b1..7da83f55f 100644 --- a/tools/coredump/testdata/arm64/java-17.ShaShenanigans.StubRoutines.sha256_implCompressMB.sha256h.json +++ b/tools/coredump/testdata/arm64/java-17.ShaShenanigans.StubRoutines.sha256_implCompressMB.sha256h.json @@ -40,7 +40,10 @@ "libjvm.so+0xbfe27b", "libjvm.so+0xe59ff7", "libjvm.so+0xe5a08f", - "" + "libjvm.so+0xdc3dcb", + "libjvm.so+0xb56fbb", + "libc.so.6+0x7edd7", + "libc.so.6+0xe7e5b" ] }, { @@ -66,7 +69,10 @@ "libjvm.so+0xbfe27b", "libjvm.so+0xe59ff7", "libjvm.so+0xe5a08f", - "" + "libjvm.so+0xdc3dcb", + "libjvm.so+0xb56fbb", + "libc.so.6+0x7edd7", + "libc.so.6+0xe7e5b" ] }, { diff --git a/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.add-sp-sp.377026.json b/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.add-sp-sp.377026.json index f74cda937..ee09766fe 100644 --- a/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.add-sp-sp.377026.json +++ b/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.add-sp-sp.377026.json @@ -121,7 +121,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { @@ -148,7 +151,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { diff --git a/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ldp-x29-x30.376761.json b/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ldp-x29-x30.376761.json index 638dd7552..f184daa81 100644 --- a/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ldp-x29-x30.376761.json +++ b/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ldp-x29-x30.376761.json @@ -55,7 +55,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { @@ -262,7 +265,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { diff --git a/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ret.377192.json b/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ret.377192.json index 2ed5dbbd4..2781725c7 100644 --- a/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ret.377192.json +++ b/tools/coredump/testdata/arm64/java.PrologueEpilogue.epi.ret.377192.json @@ -62,7 +62,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { @@ -173,7 +176,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { diff --git a/tools/coredump/testdata/arm64/java.PrologueEpilogue.stp-fp-lr.json b/tools/coredump/testdata/arm64/java.PrologueEpilogue.stp-fp-lr.json index eedcad390..0e43c3626 100644 --- a/tools/coredump/testdata/arm64/java.PrologueEpilogue.stp-fp-lr.json +++ b/tools/coredump/testdata/arm64/java.PrologueEpilogue.stp-fp-lr.json @@ -63,7 +63,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { @@ -116,7 +119,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { diff --git a/tools/coredump/testdata/arm64/java.PrologueEpilogue.sub-sp-sp.json b/tools/coredump/testdata/arm64/java.PrologueEpilogue.sub-sp-sp.json index 493d67905..c95240b56 100644 --- a/tools/coredump/testdata/arm64/java.PrologueEpilogue.sub-sp-sp.json +++ b/tools/coredump/testdata/arm64/java.PrologueEpilogue.sub-sp-sp.json @@ -26,7 +26,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { @@ -156,7 +159,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { diff --git a/tools/coredump/testdata/arm64/java.VdsoPressure.osJavaTimeNanos.649996.json b/tools/coredump/testdata/arm64/java.VdsoPressure.osJavaTimeNanos.649996.json index 9fd1d2fd5..f8709f910 100644 --- a/tools/coredump/testdata/arm64/java.VdsoPressure.osJavaTimeNanos.649996.json +++ b/tools/coredump/testdata/arm64/java.VdsoPressure.osJavaTimeNanos.649996.json @@ -127,7 +127,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { @@ -286,7 +289,10 @@ "libjvm.so+0xc09c1b", "libjvm.so+0xe597f7", "libjvm.so+0xe5988f", - "" + "libjvm.so+0xdc5633", + "libjvm.so+0xb63fbb", + "libpthread-2.33.so+0x6f3b", + "libc-2.33.so+0xd2cdb" ] }, { diff --git a/tools/coredump/testdata/arm64/ruby-3.3.9-loop-with-ractors.json b/tools/coredump/testdata/arm64/ruby-3.3.9-loop-with-ractors.json index da94fd706..2bf952133 100644 --- a/tools/coredump/testdata/arm64/ruby-3.3.9-loop-with-ractors.json +++ b/tools/coredump/testdata/arm64/ruby-3.3.9-loop-with-ractors.json @@ -49,7 +49,7 @@ "libruby.so.3.3.9+0x2ac5cf", "libruby.so.3.3.9+0x2aca0b", "libruby.so.3.3.9+0x2ac8e7", - "" + "" ] }, { diff --git a/tools/coredump/testdata/arm64/ruby-3.4.5-loop-with-ractors.json b/tools/coredump/testdata/arm64/ruby-3.4.5-loop-with-ractors.json index 21fc2919f..f7b27f3eb 100644 --- a/tools/coredump/testdata/arm64/ruby-3.4.5-loop-with-ractors.json +++ b/tools/coredump/testdata/arm64/ruby-3.4.5-loop-with-ractors.json @@ -53,7 +53,7 @@ "libruby.so.3.4.5+0x2ce9f7", "libruby.so.3.4.5+0x2cefbf", "libruby.so.3.4.5+0x2cee9f", - "" + "" ] }, { diff --git a/tools/coredump/testdata/arm64/ruby-3.5.0-loop-with-ractors.json b/tools/coredump/testdata/arm64/ruby-3.5.0-loop-with-ractors.json index 3d78bc8ea..073508ac8 100644 --- a/tools/coredump/testdata/arm64/ruby-3.5.0-loop-with-ractors.json +++ b/tools/coredump/testdata/arm64/ruby-3.5.0-loop-with-ractors.json @@ -50,7 +50,7 @@ "libruby.so.3.5.0+0x2c6a47", "libruby.so.3.5.0+0x2c700b", "libruby.so.3.5.0+0x2c6eeb", - "" + "" ] }, {