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

runtime: invalid instruction: XCHGQ with SP-relative address #19184

Closed
davidlazar opened this issue Feb 19, 2017 · 2 comments
Closed

runtime: invalid instruction: XCHGQ with SP-relative address #19184

davidlazar opened this issue Feb 19, 2017 · 2 comments

Comments

@davidlazar
Copy link
Member

$ go version
go version devel +1e69aefb7e Sat Feb 18 19:01:08 2017 +0000 linux/amd64

In the runtime directory:

$ go test -a -short -gcflags '-l=4'
# runtime                                   
./proc_runtime_test.go:34: invalid instruction: 00333 (/home/david/go/src/runtime/netpoll.go:247)	XCHGQ	AX, "".wg+24(SP)
./proc_runtime_test.go:34: invalid instruction: 00120 (/home/david/go/src/runtime/netpoll.go:272)	XCHGQ	AX, "".rg+24(SP)
# runtime
./write_err.go:14: invalid instruction: 00333 (/home/david/go/src/runtime/netpoll.go:247)	XCHGQ	AX, "".wg+24(SP)
./write_err.go:14: invalid instruction: 00120 (/home/david/go/src/runtime/netpoll.go:272)	XCHGQ	AX, "".rg+24(SP)
FAIL	runtime [build failed]

This is a result of inlining the atomicstorep function. Git bisect says that 1f77db9 is the first commit to exhibit this behavior. Prior to this commit, atomicstorep was mutually recursive,

atomicstorep -> writebarrierptr_prewrite -> writebarrierptr_prewrite1 -> writebarrierptr_prewrite1.func1 -> gcmarkwb_m -> shade -> greyobject -> (*gcWork).put -> (*gcControllerState).enlistWorker -> wakep -> startm -> newm -> allocm -> acquirep -> traceProcStart -> traceEvent -> traceStackID -> (*traceStackTable).put -> atomicstorep

which made it uninlineable. 1f77db9 broke the mutual recursion, allowing atomicstorep to get inlined.

@gopherbot
Copy link

CL https://golang.org/cl/37253 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/37255 mentions this issue.

gopherbot pushed a commit that referenced this issue Mar 1, 2017
Make sure that if we encode an explicit base register, we print it.
That will ensure that if we make an Addr with an auto variable but
a base that isn't SP, then it will be obvious from the disassembly.

Update #19184

Change-Id: If5556a5183f344d719ec7197aa935a0166061e6f
Reviewed-on: https://go-review.googlesource.com/37255
Reviewed-by: Cherry Zhang <cherryyz@google.com>
@golang golang locked and limited conversation to collaborators Feb 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants