Skip to content

debug: handle storage-free Python attributes#2145

Open
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/dwarf-python-types
Open

debug: handle storage-free Python attributes#2145
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/dwarf-python-types

Conversation

@cpunion

@cpunion cpunion commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Problem

Python module attributes are frontend pseudo-variables. LLGo loads and stores them through Python C API calls, so their ssa.Expr has a source-facing type but no native LLVM global or address.

With DWARF enabled, the generic global path tried to derive a native debug type and attach a DIGlobalVariableExpression to that absent storage. Compiling _testpy/list therefore reached pyVarTy.Underlying and panicked with don't call.

Changes

  • make ssa.Builder.DIGlobal ignore expressions that have no native LLVM storage
  • keep ordinary Go and C globals on the existing DWARF path
  • do not emit a fake address or misleading DW_TAG_variable for dynamically resolved Python attributes
  • add a focused unit test using a real storage-free Python variable expression
  • run the complete _testpy fixture set with DWARF enabled on supported hosts

Fixes #2117.

Verification

macOS arm64, Go 1.26.5 / LLVM 19:

  • all 8 _testpy fixtures pass with DWARF
  • full go test ./ssa passes
  • standards-based DWARF matrix passes at O0, O1, O2, O3, Os, and Oz
  • the changed DIGlobal paths are covered directly

Ubuntu arm64 container, limited to 2 CPUs, 15 GiB memory, and 512 PIDs:

  • 7 stable _testpy fixtures pass with DWARF
  • standards-based DWARF matrix passes at all six optimization levels
  • _testpy/matrix still reproduces the same existing runtime crash with and without DWARF; this PR does not add a skip or hide that baseline failure

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@cpunion cpunion changed the title [Based on #2141] debug: ignore storage-free Python globals [Based on #2141] debug: handle storage-free Python attributes Jul 22, 2026
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpunion cpunion changed the title [Based on #2141] debug: handle storage-free Python attributes debug: handle storage-free Python attributes Jul 22, 2026
@cpunion
cpunion force-pushed the codex/dwarf-python-types branch from a1df5de to b178917 Compare July 22, 2026 09:20
@cpunion
cpunion marked this pull request as ready for review July 22, 2026 09:21
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

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.

DWARF: handle frontend-specific types without compiler panic

1 participant