Skip to content

DWARF: avoid aggregate-return segfault in cabisret #2121

Description

@cpunion

Summary

The _demo/c/cabisret large-aggregate return workload segfaults when LLGo's current DWARF path is enabled. The same source runs correctly when DWARF is omitted.

Despite the directory name, this reproducer is pure Go and stresses a 9-element float32 array wrapped in a struct, passed and returned repeatedly by value.

Reproduction

Confirmed locally on native Linux/arm64 with Go 1.26.5 and the current compiler from #2120:

cd _demo/c/cabisret
llgo run -ldflags=-w=false .

Result:

signal: segmentation fault

Control:

llgo run -ldflags=-w .

Result:

262145 2

The default-DWARF CI run https://github.com/xgo-dev/llgo/actions/runs/29549966202 reproduces the segfault on Linux arm64, macOS arm64, and macOS amd64 with both Go 1.24 and Go 1.26 lanes.

Analysis

-w=false currently enables ssa.GlobalDebug and also disables both the LLVM pass pipeline and C ABI optimization. The failing value crosses LLGo's aggregate return/lowering path many times, so the current evidence points to the DWARF-enabled codegen configuration rather than pclntab or runtime symbol lookup.

The next isolation step should compile the workload under all combinations of:

  • ssa.GlobalDebug on/off;
  • passOpt on/off;
  • cabiOptimize on/off.

Then compare the demo1/demo2 signatures, sret storage lifetime/alignment, aggregate copies, and call-site attributes in LLVM IR. A small one-call aggregate-return test should be added once the first invalid combination is identified; the long loop makes the symptom reliable but is larger than the likely root cause.

Expected behavior

Debug information and optimization selection must not change aggregate ABI correctness. The workload must print 262145 2 with both -w=false and -w on every supported native architecture.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions