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/internal/obj/mips: assembler panic when assemble neg instruction #23548

Closed
crvv opened this issue Jan 25, 2018 · 2 comments
Closed

cmd/internal/obj/mips: assembler panic when assemble neg instruction #23548

crvv opened this issue Jan 25, 2018 · 2 comments

Comments

@crvv
Copy link
Contributor

crvv commented Jan 25, 2018

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

1.9.3 and tip(1b69d19)

What did you do?

Create the following file.
Run GOARCH=mips GOOS=linux go tool asm asm.s or GOARCH=mips64 GOOS=linux go tool asm asm.s

asm.s

TEXT ·a(SB),0,$0
    NEGW R1, R1
    RET

What did you expect to see?

Success or a failure without panic.

What did you see instead?

$ GOARCH=mips64 GOOS=linux go tool asm asm.s
# package/path
asm: illegal combination NEGW REG NONE REG
00000 (./asm.s:2)	NEGW	R1, R1
asm: illegal combination NEGW REG NONE REG
00000 (./asm.s:2)	NEGW	R1, R1
asm: illegal combination NEGW REG NONE REG
00000 (./asm.s:2)	NEGW	R1, R1
asm: bad irr opcode NEGW
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0 pc=0x10ec707]

goroutine 1 [running]:
cmd/internal/obj/mips.(*ctxt0).asmout(0xc420055bc8, 0xc420093380, 0x127e940, 0xc420055b60, 0x4, 0x4)
	$GOROOT/src/cmd/internal/obj/mips/asm0.go:1237 +0xac7
cmd/internal/obj/mips.span0(0xc4200bc000, 0xc4200c6000, 0xc42005e3c0)
	$GOROOT/src/cmd/internal/obj/mips/asm0.go:500 +0x7c8
cmd/internal/obj.Flushplist(0xc4200bc000, 0xc420055e50, 0xc42005e3c0, 0x0, 0x0)
	$GOROOT/src/cmd/internal/obj/plist.go:107 +0x6ca
main.main()
	$GOROOT/src/cmd/asm/main.go:75 +0x543
@crvv crvv changed the title cmd/internal/obj/mips: compiler panic when assemble neg instruction cmd/internal/obj/mips: assembler panic when assemble neg instruction Jan 25, 2018
@cherrymui
Copy link
Member

It doesn't support NEGW instruction. You should do SUBVU R1, R0, R1 on MIPS64 or SUBU R1, R0, R1 on MIPS32.

We should remove NEGW from instruction list.

@cherrymui cherrymui self-assigned this Jan 25, 2018
@gopherbot
Copy link

Change https://golang.org/cl/89896 mentions this issue: cmd/internal/obj/mips: remove NEGW, avoid crash with illegal instruction

@golang golang locked and limited conversation to collaborators Feb 14, 2019
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

3 participants