#2861·xgo

XGo v1.7.5 panics on xgo run hello.xgo with Go 1.27.1 on macOS arm64

Author: minorcellCreated Sep 24, 2026Updated Sep 29, 2026
Labelsbug

XGo v1.7.5 panics on xgo run hello.xgo with Go 1.27.1 on macOS arm64

The following program hello.xgo triggers an unexpected result

This is the Hello World example from the XGo documentation:

xgo
println "Hello world"

Expected result

Hello world

Got

$ xgo run hello.xgo
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x148 pc=0x44526b7]

goroutine 1 [running]:
github.com/goplus/gogen.(*Package).ForEachFile(...)
        github.com/goplus/[email protected]/package.go:486
github.com/goplus/xgo/tool.checkGopDeps(...)
        github.com/goplus/xgo/tool/load.go:338
github.com/goplus/xgo/tool.afterLoad(0x4b39b80, 0xb8caac28960, 0x0, 0x0, 0xb8caac0d810)
        github.com/goplus/xgo/tool/load.go:322 +0xd7
github.com/goplus/xgo/tool.LoadFiles({0x4527b40?, 0x7751d80?}, {0xb8caaaf26f0, 0x1, 0x1}, 0x0?)
        github.com/goplus/xgo/tool/load.go:408 +0x47d
github.com/goplus/xgo/tool.GenGoFiles({0x0?, 0x0?}, {0xb8caaaf26f0, 0x1, 0x1}, 0x3ff697f?)
        github.com/goplus/xgo/tool/gengo.go:289 +0xda
github.com/goplus/xgo/tool.RunFiles({0x0, 0x0}, {0xb8caaaf26f0?, 0xb8caaaf7850?, 0x3f81845?}, {0xb8caaaf26f0, 0x0, 0x0}, 0xb8caac0d810, 0xb8caac40240)
        github.com/goplus/xgo/tool/build_install_run.go:168 +0x57
github.com/goplus/xgo/cmd/internal/run.run({0x4aada38?, 0xb8caaab6768?}, {0xb8caaaf26f0?, 0xb8caaaf7950?, 0x1?}, 0x1?, 0x3f0de7b?, 0x22?)
        github.com/goplus/xgo/cmd/internal/run/run.go:109 +0xf2

XGo Version

v1.7.5 darwin/amd64

Additional Notes

I installed XGo with brew install xgo, following the installation documentation. On this Apple Silicon Mac, the installed XGo binary is x86_64, while Go is arm64. I have not determined whether this architecture difference contributes to the panic.

Environment:

$ sw_vers
ProductName:		macOS
ProductVersion:		27.0

$ uname -m
arm64

$ file /usr/local/bin/xgo
/usr/local/bin/xgo: Mach-O 64-bit executable x86_64

$ brew --version
Homebrew 7.0.6

$ go version
go version go1.27.1 darwin/arm64

Issue #2307 reports a similar gogen.(*Package).ForEachFile panic, but with older XGo and Go versions.

To reproduce:

  1. Install XGo with Homebrew:

    bash
    brew install xgo
  2. Save the program above as hello.xgo.

  3. Run it:

    bash
    xgo run hello.xgo