4ad/go

test/method: sigsegv failure when SSA-built

Closed this issue · 1 comments

test/method.go currently seg faults when SSA-built and then executed on a sparc64 system.

It is cross-compiled and cross-linked for sparc64 from an amd64 system using:

SSATEST=1 GOSSAHASH="" GOOS=solaris GOARCH=sparc64 go tool compile method.go
GOOS=solaris GOARCH=sparc64 go tool link method.o

When executed it fails as follows:

$ ./method
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x8]

goroutine 1 [running]:
panic(0xcdb40, 0x111170)
        /builds/srwalker/golang/go-sparc/src/runtime/panic.go:507 +0x5f8

This was because we were using AJMP instead of ARET in the ssa backend when generating the code for a BlockRetJmp. The obj backend for sparc64 has a special case for a return with a symbol; this also ensures the function gets marked as a leaf later on.

See #20 for details.

Fixing this resolves both #20 and #24.