Skip to content

Conversation

@vtjnash
Copy link
Member

@vtjnash vtjnash commented Nov 1, 2025

Add fake_stack_pop implementation for Linux platforms to improve stack unwinding in debuggers when analyzing core dumps from signals like SIGQUIT. This provides proper DWARF Call Frame Information (CFI) directives that help unwinders locate saved register values on the manipulated stack.

The implementation follows the same pattern as the existing macOS version, with fake_stack_pop now unified in signals-unix.c to support both platforms:

  • x86_64: Uses .cfi_def_cfa %rsp with offsets for %rip and %rsp
  • i686: Uses .cfi_def_cfa %esp with offsets for %eip and %esp
  • aarch64: Uses .cfi_def_cfa sp with offsets for lr and sp

The jl_call_in_ctx function on Linux now sets up the stack similarly to jl_call_in_state on macOS, pushing saved register state and a return address pointing to fake_stack_pop to enable proper unwinding.

🤖 Generated with Claude Code

@giordano
Copy link
Member

giordano commented Nov 1, 2025

How about riscv64?

@vtjnash vtjnash force-pushed the jn/fake_stack_pop-linux branch from a2aac97 to d7e2f3d Compare November 3, 2025 16:53
@vtjnash vtjnash changed the title signals: Implement fake_stack_pop for Linux on x86_64, i686, and aarch64 signals: Implement fake_stack_pop for Linux on x86_64 and i686 Nov 4, 2025
Add jl_fake_signal_return (was fake_stack_pop) implementation for Linux
platforms to improve stack unwinding in debuggers when analyzing core
dumps from signals like SIGQUIT. This provides proper DWARF Call Frame
Information (CFI) directives that help unwinders locate saved register
values on the manipulated stack.

The implementation follows the same pattern as the existing macOS version,
with fake_stack_pop now unified in signals-unix.c to support both platforms:
- x86_64: Uses .cfi_def_cfa %rsp with offsets for %rip and %rsp
- i686: Uses .cfi_def_cfa %esp with offsets for %eip and %esp
- aarch64: Uses .cfi_def_cfa sp with offsets for lr and sp
- uses file scope assembly, since aarch64 gcc has an open bug about
  implementing the naked attribute.

The jl_call_in_ctx function on Linux now sets up the stack similarly to
jl_call_in_state on macOS, pushing saved register state and a return address
pointing to fake_stack_pop to enable proper unwinding.

🤖 Generated with Claude Code
@vtjnash vtjnash force-pushed the jn/fake_stack_pop-linux branch from 522d4c0 to 1414990 Compare November 7, 2025 19:47
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Nov 7, 2025
@fingolfin
Copy link
Member

CI failures might be "real"?

Error in testset cmdlineargs:
Test Failed at /cache/build/tester-amdci4-10/julialang/julia-master/julia-1414990672/share/julia/test/cmdlineargs.jl:103
  Expression: Base.process_signaled(p) && p.termsignal == Base.SIGQUIT
Error in testset cmdlineargs:
Test Failed at /cache/build/tester-amdci4-10/julialang/julia-master/julia-1414990672/share/julia/test/cmdlineargs.jl:104
  Expression: occursin("==== Thread ", err_s)
   Evaluated: occursin("==== Thread ", "\n[3473] signal 11 (128): Segmentation fault\nin expression starting at none:8\njl_exit_thread0_cb at /cache/build/builder-amdci4-1/julialang/julia-master/src/signals-unix.c:660\nAllocations: 1 (Pool: 1; Big: 0); GC: 0")
Error in testset cmdlineargs:
Test Failed at /cache/build/tester-amdci4-10/julialang/julia-master/julia-1414990672/share/julia/test/cmdlineargs.jl:105
  Expression: occursin("==== Done", err_s)
   Evaluated: occursin("==== Done", "\n[3473] signal 11 (128): Segmentation fault\nin expression starting at none:8\njl_exit_thread0_cb at /cache/build/builder-amdci4-1/julialang/julia-master/src/signals-unix.c:660\nAllocations: 1 (Pool: 1; Big: 0); GC: 0")
ERROR: LoadError: Test run finished with errors
in expression starting at /cache/build/tester-amdci4-10/julialang/julia-master/julia-1414990672/share/julia/test/runtests.jl:102

@fingolfin fingolfin removed the merge me PR is reviewed. Merge when all tests are passing label Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants