Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/asm: NOP function crashes asm when building for arm64 #20348

Closed
stapelberg opened this issue May 12, 2017 · 2 comments
Closed

cmd/asm: NOP function crashes asm when building for arm64 #20348

stapelberg opened this issue May 12, 2017 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@stapelberg
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version devel +380aa884b8 Fri May 12 18:08:12 2017 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="arm64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/michael/go"
GORACE=""
GOROOT="/tmp/upstream-go"
GOTOOLDIR="/tmp/upstream-go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build622527587=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="0"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

$ head -50 repro.go repro_arm64.s 
==> repro.go <==
package main

func stub()

func main() {
        stub()
}

==> repro_arm64.s <==
TEXT ·stub(SB),$0-0
        NOP

I ran GOARCH=arm64 go build on an amd64 host machine.

What did you expect to see?

I think the definition of ·stub is invalid, as it’s missing a RET instruction. Still, the assembler shouldn’t crash, should it?

What did you see instead?

$ GOARCH=arm64 /tmp/upstream-go/bin/go build         
# asm-crash-repro
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xaa pc=0x4f7760]

goroutine 1 [running]:
cmd/internal/obj/arm64.preprocess(0xc42007a100, 0xc4200a6000, 0xc42004e380)
        /tmp/upstream-go/src/cmd/internal/obj/arm64/obj7.go:469 +0x210
cmd/internal/obj.Flushplist(0xc42007a100, 0xc420045e50, 0xc42004e380)
        /tmp/upstream-go/src/cmd/internal/obj/plist.go:106 +0x692
main.main()
        /tmp/upstream-go/src/cmd/asm/main.go:75 +0x5d1

This issue is reproducible with go1.8.1.

@andybons
Copy link
Member

@ianlancetaylor @josharian

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 11, 2018
@andybons andybons added this to the Unplanned milestone Apr 11, 2018
@gopherbot
Copy link

Change https://golang.org/cl/106457 mentions this issue: cmd/internal/obj/arm64: don't crash on trailing NOP

@golang golang locked and limited conversation to collaborators Apr 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants