Skip to content

Commit eab1249

Browse files
committed
Address pair-review feedback for FP unwinding
- Fix doc comment placement: move hasJitFramePointers comment to directly above the function definition instead of above findJITRegion - Fix containerized process support: use /proc/PID/root/tmp/ to access container filesystem for perf map detection, and glob perf-*.map to handle namespace PID mismatch (Ruby uses ns-local PID in filename) - Remove os import (replaced by path/filepath for Glob) - Rebuild BPF blobs
1 parent 444d984 commit eab1249

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

interpreter/ruby/ruby.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"errors"
1010
"fmt"
1111
"math/bits"
12-
"os"
12+
"path/filepath"
1313
"regexp"
1414
"runtime"
1515
"strconv"
@@ -1281,11 +1281,6 @@ func profileFrameFullLabel(classPath, label, baseLabel, methodName libpf.String,
12811281
return libpf.Intern(profileLabel)
12821282
}
12831283

1284-
// hasJitFramePointers detects whether YJIT is emitting frame pointers for this process.
1285-
// On arm64, YJIT always emits frame pointers unconditionally.
1286-
// On x86_64, frame pointers are only emitted when --yjit-perf or --yjit-perf=fp is used.
1287-
// When --yjit-perf is active, YJIT also creates /tmp/perf-PID.map, which we use as the
1288-
// detection signal on x86_64.
12891284
// findJITRegion detects the YJIT JIT code region from process memory mappings.
12901285
// YJIT reserves a large contiguous address range (typically 48-128 MiB) via mmap
12911286
// with PROT_NONE and then mprotects individual 16k codepages to r-x as needed.
@@ -1336,6 +1331,11 @@ func findJITRegion(mappings []process.RawMapping) (uint64, uint64, bool) {
13361331
return 0, 0, false
13371332
}
13381333

1334+
// hasJitFramePointers detects whether YJIT is emitting frame pointers for this process.
1335+
// On arm64, YJIT always emits frame pointers unconditionally.
1336+
// On x86_64, frame pointers are only emitted when --yjit-perf or --yjit-perf=fp is used.
1337+
// When --yjit-perf is active, YJIT also creates /tmp/perf-PID.map, which we use as the
1338+
// detection signal on x86_64.
13391339
func hasJitFramePointers(pr process.Process) bool {
13401340
machine := pr.GetMachineData().Machine
13411341
if machine == elf.EM_AARCH64 {
@@ -1345,8 +1345,11 @@ func hasJitFramePointers(pr process.Process) bool {
13451345

13461346
// On x86_64, check for the perf map file which indicates --yjit-perf was used.
13471347
// The --yjit-perf flag enables both frame pointers and the perf map.
1348-
perfMapPath := fmt.Sprintf("/tmp/perf-%d.map", pr.PID())
1349-
if _, err := os.Stat(perfMapPath); err == nil {
1348+
// We access via /proc/PID/root/tmp/ to handle containerized processes with
1349+
// different mount namespaces. We glob perf-*.map because Ruby uses its
1350+
// namespace-local PID for the filename, which differs from the host PID.
1351+
perfMapPattern := fmt.Sprintf("/proc/%d/root/tmp/perf-*.map", pr.PID())
1352+
if matches, err := filepath.Glob(perfMapPattern); err == nil && len(matches) > 0 {
13501353
return true
13511354
}
13521355

support/ebpf/tracer.ebpf.amd64

0 Bytes
Binary file not shown.

support/ebpf/tracer.ebpf.arm64

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)