[Bug libc/34338] New: Cancellable syscall wrappers are missing from backtraces because they tail-call __syscall_cancel

"adhemerval.zanella at linaro dot org via Glibc-bugs" <[email protected]> Tue, 30 Jun 2026 17:28:38 +0000
Newsgroups gmane.comp.lib.glibc.bugs
Message-ID <[email protected]/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=34338

            Bug ID: 34338
           Summary: Cancellable syscall wrappers are missing from
                    backtraces because they tail-call __syscall_cancel
           Product: glibc
           Version: 2.41
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: adhemerval.zanella at linaro dot org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The cancellable syscall wrappers end with

    return SYSCALL_CANCEL (write, fd, buf, nbytes);

which is a tail call to the 7-argument __syscall_cancel.  On targets that pass
all seven arguments in registers and need no GOT/TOC restore after a call, the
compiler emits a sibling call and the wrapper frame is elided. When the syscall
executes, the wrapper is no longer on the stack, so debuggers, valgrind, perf
and sampling profilers cannot see it.  gdb can only recover the frame from
DWARF call-site info, which reduced-debuginfo libc builds usually omit.

x86_64 is unaffected: __syscall_cancel's 7th argument is passed on the stack,
which inhibits the sibling call and keeps the wrapper frame.  This is why the
problem appears aarch64-specific.

For a shared libc.so the tail call is emitted on aarch64, arc, loongarch and
riscv; powerpc and mips emit it only in non-PIC builds.

This was added by 89b53077d2a58f00e7debdfe58afabe953dac60d.

Related: valgrind bug 502126; thread
https://inbox.sourceware.org/libc-alpha/[email protected]

-- 
You are receiving this mail because:
You are on the CC list for the bug.