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/compile: SIGBUS unaligned access on mips64 via qemu-mips64 #67160

Closed
jwhited opened this issue May 3, 2024 · 7 comments
Closed

cmd/compile: SIGBUS unaligned access on mips64 via qemu-mips64 #67160

jwhited opened this issue May 3, 2024 · 7 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jwhited
Copy link

jwhited commented May 3, 2024

Go version

go version go1.22.2 linux/amd64 (emulated mips64 via qemu-mips64; qemu-user pkg on most distros)

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jwhited/.cache/go-build'
GOENV='/home/jwhited/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/jwhited/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jwhited/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1623647663=/tmp/go-build -gno-record-gcc-switches'

What did you do?

package main

import "fmt"

type udpFlowKey struct {
	srcAddr, dstAddr [16]byte
	srcPort, dstPort uint16
	isV6             bool
}

type udpGROItem struct {
	key udpFlowKey
}

func main() {
	itemsByFlow := make(map[udpFlowKey][]udpGROItem)
	key := udpFlowKey{}
	items := make([]udpGROItem, 0)
	items = append(items, udpGROItem{
		key: key,
	})
	itemsByFlow[key] = items
	b, _ := itemsByFlow[key]
	fmt.Println(b)
}

via -exec qemu-mips64:

GOOS=linux GOARCH=mips64 go run -exec qemu-mips64 main.go

What did you see happen?

jwhited@i5-12400-2:~$ GOOS=linux GOARCH=mips64 go run -exec qemu-mips64 main.go
unexpected fault address 0xc00010accc
fatal error: fault
[signal SIGBUS: bus error code=0x1 addr=0xc00010accc pc=0x14eac]

goroutine 1 gp=0xc000002380 m=0 mp=0x16e8e0 [running]:
runtime.throw({0xda3f9, 0x5})
	/usr/local/go/src/runtime/panic.go:1023 +0x58 fp=0xc00010abb0 sp=0xc00010ab88 pc=0x55d00
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:878 +0x278 fp=0xc00010ac10 sp=0xc00010abb0 pc=0x76fe0
runtime.memequal128(0xc00010accc, 0xc00010ad40)
	/usr/local/go/src/runtime/alg.go:285 +0x4 fp=0xc00010ac18 sp=0xc00010ac18 pc=0x14eac
type:.eq.main.udpFlowKey(0xc00010accc, 0xc00010ad40)
	<autogenerated>:1 +0x88 fp=0xc00010ac38 sp=0xc00010ac18 pc=0xbfa80
runtime.mapaccess2(0xcaa20, 0xc00010af38, 0xc00010accc)
	/usr/local/go/src/runtime/map.go:506 +0x2cc fp=0xc00010ac78 sp=0xc00010ac38 pc=0x21ec4
main.main()
	/home/jwhited/main.go:23 +0x1d8 fp=0xc00010af68 sp=0xc00010ac78 pc=0xbf908
runtime.main()
	/usr/local/go/src/runtime/proc.go:271 +0x39c fp=0xc00010afd8 sp=0xc00010af68 pc=0x59874
runtime.goexit({})
	/usr/local/go/src/runtime/asm_mips64x.s:671 +0x4 fp=0xc00010afd8 sp=0xc00010afd8 pc=0x971ac

goroutine 2 gp=0xc0000028c0 m=nil [force gc (idle)]:
runtime.gopark(0xe2c08, 0x16e030, 0x11, 0xa, 0x1)
	/usr/local/go/src/runtime/proc.go:402 +0x140 fp=0xc000048fa8 sp=0xc000048f90 pc=0x59f18
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:408
runtime.forcegchelper()
	/usr/local/go/src/runtime/proc.go:326 +0x13c fp=0xc000048fd8 sp=0xc000048fa8 pc=0x59cec
runtime.goexit({})
	/usr/local/go/src/runtime/asm_mips64x.s:671 +0x4 fp=0xc000048fd8 sp=0xc000048fd8 pc=0x971ac
created by runtime.init.5 in goroutine 1
	/usr/local/go/src/runtime/proc.go:314 +0x48

goroutine 3 gp=0xc000003180 m=nil [GC sweep wait]:
runtime.gopark(0xe2c08, 0x16e180, 0xc, 0x9, 0x1)
	/usr/local/go/src/runtime/proc.go:402 +0x140 fp=0xc000049788 sp=0xc000049770 pc=0x59f18
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:408
runtime.bgsweep(0xc000070000)
	/usr/local/go/src/runtime/mgcsweep.go:278 +0x108 fp=0xc0000497c8 sp=0xc000049788 pc=0x3e2d8
runtime.gcenable.gowrap1()
	/usr/local/go/src/runtime/mgc.go:203 +0x64 fp=0xc0000497d8 sp=0xc0000497c8 pc=0x2da4c
runtime.goexit({})
	/usr/local/go/src/runtime/asm_mips64x.s:671 +0x4 fp=0xc0000497d8 sp=0xc0000497d8 pc=0x971ac
created by runtime.gcenable in goroutine 1
	/usr/local/go/src/runtime/mgc.go:203 +0xc4

goroutine 4 gp=0xc000003340 m=nil [GC scavenge wait]:
runtime.gopark(0xe2c08, 0x16e2c0, 0xd, 0xa, 0x2)
	/usr/local/go/src/runtime/proc.go:402 +0x140 fp=0xc000049f80 sp=0xc000049f68 pc=0x59f18
runtime.goparkunlock(...)
	/usr/local/go/src/runtime/proc.go:408
runtime.(*scavengerState).park(0x16e2c0)
	/usr/local/go/src/runtime/mgcscavenge.go:425 +0x9c fp=0xc000049fa8 sp=0xc000049f80 pc=0x3ae2c
runtime.bgscavenge(0xc000070000)
	/usr/local/go/src/runtime/mgcscavenge.go:653 +0x80 fp=0xc000049fc8 sp=0xc000049fa8 pc=0x3b570
runtime.gcenable.gowrap2()
	/usr/local/go/src/runtime/mgc.go:204 +0x64 fp=0xc000049fd8 sp=0xc000049fc8 pc=0x2d9d4
runtime.goexit({})
	/usr/local/go/src/runtime/asm_mips64x.s:671 +0x4 fp=0xc000049fd8 sp=0xc000049fd8 pc=0x971ac
created by runtime.gcenable in goroutine 1
	/usr/local/go/src/runtime/mgc.go:204 +0x130

goroutine 17 gp=0xc00010e1c0 m=nil [finalizer wait]:
runtime.gopark(0xe2b48, 0x1cb8c8, 0x10, 0xa, 0x1)
	/usr/local/go/src/runtime/proc.go:402 +0x140 fp=0xc000048730 sp=0xc000048718 pc=0x59f18
runtime.runfinq()
	/usr/local/go/src/runtime/mfinal.go:194 +0x198 fp=0xc0000487d8 sp=0xc000048730 pc=0x2c408
runtime.goexit({})
	/usr/local/go/src/runtime/asm_mips64x.s:671 +0x4 fp=0xc0000487d8 sp=0xc0000487d8 pc=0x971ac
created by runtime.createfing in goroutine 1
	/usr/local/go/src/runtime/mfinal.go:164 +0xa8
exit status 2

What did you expect to see?

The expected program output is:

jwhited@i5-12400-2:~$ go run main.go
[{{[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 0 0 false}}]
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 3, 2024
@randall77
Copy link
Contributor

This sounds like #46283. What about the fix for that issue isn't working here? Strange...

@randall77
Copy link
Contributor

Probably the rewrite of type equality code in https://go-review.googlesource.com/c/go/+/399542
@derekparker

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/583175 mentions this issue: cmd/compile: don't combine loads in generated equality functions

@randall77
Copy link
Contributor

@gopherbot please open backport issues.

This looks like it started in 1.20. So maybe that CL isn't to blame? I think it would have landed in 1.21 if I'm getting my math right.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #67164 (for 1.21).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@derekparker
Copy link
Contributor

@randall77 If I'm not mistaken my CL you mentioned would have landed in 1.19, it was merged Apr 21, 2022 and the 1.19 tree had just opened the month before (#51336 (comment)).

That being said, I'm not sure if my CL introduced the bug or not. It was largely a refactoring to prepare for https://go-review.googlesource.com/c/go/+/411674 which did end up landing in 1.20. The function eqmemfunc modified in your change was just copied over by me in that CL. That's not to say eqmemfunc would have been called after that CL when it previously would not have. Regardless, apologies if I did end up introducing (or surfacing) this bug!

@randall77
Copy link
Contributor

@gopherbot please open a backport issue for 1.22.

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label May 6, 2024
@dmitshur dmitshur added this to the Go1.23 milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants