Skip to content

cmd/compile: test/inline_sync.go test fails if GOARM64=v8.1 #67229

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

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

cmd/compile: test/inline_sync.go test fails if GOARM64=v8.1 #67229

andreybokhanko opened this issue May 7, 2024 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@andreybokhanko
Copy link
Contributor

andreybokhanko commented May 7, 2024

Go version

trunk

Output of go env in your module/workspace:

GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/home/abokhanko/.cache/go-build"
GOENV="/home/abokhanko/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/abokhanko/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/abokhanko/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/abokhanko/goroot"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/abokhanko/goroot/pkg/tool/linux_arm64"
GOVCS=""
GOVERSION="go1.20.13"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1657645440=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ cd $GOROOT/src
$ GOARM64=v8.1 ../bin/go test cmd/internal/testdir -run=Test/inline_sync.go

What did you see happen?

--- FAIL: Test (0.04s)
    --- FAIL: Test/inline_sync.go (0.41s)
        testdir_test.go:145: exit status 1
            /home/abokhanko/goroot/test/inline_sync.go:26: can inline small5
            /home/abokhanko/goroot/test/inline_sync.go:31: can inline small6
            /home/abokhanko/goroot/test/inline_sync.go:38: can inline small7
            /home/abokhanko/goroot/test/inline_sync.go:45: can inline small8
            /home/abokhanko/goroot/test/inline_sync.go:50: can inline small9
            /home/abokhanko/goroot/test/inline_sync.go:28: inlining call to sync.(*Mutex).Unlock
            /home/abokhanko/goroot/test/inline_sync.go:33: inlining call to sync.(*Mutex).Lock
            /home/abokhanko/goroot/test/inline_sync.go:40: inlining call to sync.(*Once).Do
            /home/abokhanko/goroot/test/inline_sync.go:40: inlining call to atomic.(*Uint32).Load
            /home/abokhanko/goroot/test/inline_sync.go:47: inlining call to sync.(*RWMutex).RUnlock
            /home/abokhanko/goroot/test/inline_sync.go:47: inlining call to atomic.(*Int32).Add
            /home/abokhanko/goroot/test/inline_sync.go:52: inlining call to sync.(*RWMutex).RLock
            /home/abokhanko/goroot/test/inline_sync.go:52: inlining call to atomic.(*Int32).Add
            /home/abokhanko/goroot/test/inline_sync.go:33: internal compiler error: 'small6': if block b1 has non-bool control value v13 = Select0 <uint32> v11

            goroutine 1 [running]:
            runtime/debug.Stack()
                /home/abokhanko/goroot/src/runtime/debug/stack.go:26 +0x64
            cmd/compile/internal/base.FatalfAt({0x4f5408?, 0x40?}, {0x4000022f90, 0x2f}, {0x4000678990, 0x3, 0x3})
                /home/abokhanko/goroot/src/cmd/compile/internal/base/print.go:225 +0x200
            cmd/compile/internal/base.Fatalf(...)
                /home/abokhanko/goroot/src/cmd/compile/internal/base/print.go:194
            cmd/compile/internal/ssagen.(*ssafn).Fatalf(0x4000180008?, {0x1b3350?, 0x40?}, {0x9708a9, 0x29}, {0x40005590e0, 0x2, 0x40004f5488?})
                /home/abokhanko/goroot/src/cmd/compile/internal/ssagen/ssa.go:8208 +0x150
            cmd/compile/internal/ssa.(*Func).Fatalf(0x40004e7a00, {0x9708a9, 0x29}, {0x40005590e0, 0x2, 0x2})
                /home/abokhanko/goroot/src/cmd/compile/internal/ssa/func.go:741 +0x25c
            cmd/compile/internal/ssa.checkFunc(0x40004e7a00)
                /home/abokhanko/goroot/src/cmd/compile/internal/ssa/check.go:85 +0x6e0
            cmd/compile/internal/ssa.Compile(0x40004e7a00)
                /home/abokhanko/goroot/src/cmd/compile/internal/ssa/compile.go:67 +0x314
            cmd/compile/internal/ssagen.buildssa(0x40004eab40, 0x0)
                /home/abokhanko/goroot/src/cmd/compile/internal/ssagen/ssa.go:574 +0x1f80
            cmd/compile/internal/ssagen.Compile(0x40004eab40, 0x0)
                /home/abokhanko/goroot/src/cmd/compile/internal/ssagen/pgen.go:300 +0x30
            cmd/compile/internal/gc.compileFunctions.func5.1(0x4000180001?)
                /home/abokhanko/goroot/src/cmd/compile/internal/gc/compile.go:182 +0x3c
            cmd/compile/internal/gc.compileFunctions.func2(0x40005589c0?)
                /home/abokhanko/goroot/src/cmd/compile/internal/gc/compile.go:136 +0x28
            cmd/compile/internal/gc.compileFunctions.func5({0x4000562080, 0x5, 0x9890b8?})
                /home/abokhanko/goroot/src/cmd/compile/internal/gc/compile.go:181 +0x60
            cmd/compile/internal/gc.compileFunctions()
                /home/abokhanko/goroot/src/cmd/compile/internal/gc/compile.go:192 +0x1f4
            cmd/compile/internal/gc.Main(0x988f00)
                /home/abokhanko/goroot/src/cmd/compile/internal/gc/main.go:303 +0x1264
            main.main()
                /home/abokhanko/goroot/src/cmd/compile/main.go:57 +0x110


FAIL
FAIL    cmd/internal/testdir    0.455s
FAIL

What did you expect to see?

Test passes

@andreybokhanko
Copy link
Contributor Author

The reason of the fail is incorrect SSA generated:

$ GOSSAFUNC=small6+ GOARM64=v8.1 ../bin/go test cmd/internal/testdir -run=Test/inline_sync.go
...
            compiling small6
            small6 func()
              b1:
                (?) v1 = InitMem <mem>
                (?) v2 = SP <uintptr> DEAD
                (?) v3 = SB <uintptr>
                (?) v4 = Addr <**sync.Mutex> {p.mutex} v3
                (33) v5 = Load <*sync.Mutex> v4 v1 (sync.m[*sync.Mutex])
                (+33) v6 = InlMark <void> [1] v1
                (83) v7 = NilCheck <*sync.Mutex> v5 v1
                (83) v8 = OffPtr <*int32> [0] v7
                (?) v9 = Const32 <int32> [0]
                (?) v10 = Const32 <int32> [1]
                (83) v11 = AtomicCompareAndSwap32Variant <bool,mem> v8 v9 v10 v1
                (83) v12 = Select1 <mem> v11
                (83) v13 = Select0 <uint32> v11
                If v13 -> b3 b2
              b2: <- b1
                (-90) v14 = Copy <*sync.Mutex> v5 (sync.m[*sync.Mutex])
                (-90) v15 = Copy <mem> v12
                (90) v16 = StaticLECall <mem> {AuxCall{sync.(*Mutex).lockSlow}} [8] v14 v15
                (90) v17 = SelectN <mem> [0] v16
                Plain -> b4
              b3: <- b1
                Plain -> b4
              b4: <- b3 b2
                (-34) v18 = Phi <mem> v12 v17
                (34) v19 = MakeResult <mem> v18
                Ret v19
            name sync.m[*sync.Mutex]: [v5 v14]

as can be seen, second Select instruction from this fragment:

                (83) v11 = AtomicCompareAndSwap32Variant <bool,mem> v8 v9 v10 v1
                (83) v12 = Select1 <mem> v11
                (83) v13 = Select0 <uint32> v11

is of wrong type -- uint32 instead of bool.

@andreybokhanko
Copy link
Contributor Author

I have a fix ready for this; please assign this ticket on me.

@cherrymui cherrymui changed the title cmd/go: inline_sync.go test fails if GOARM64=v8.1 cmd/compile: inline_sync.go test fails if GOARM64=v8.1 May 7, 2024
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 7, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 7, 2024
@cherrymui cherrymui added this to the Go1.23 milestone May 7, 2024
@cherrymui cherrymui changed the title cmd/compile: inline_sync.go test fails if GOARM64=v8.1 cmd/compile: test/inline_sync.go test fails if GOARM64=v8.1 May 7, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/583995 mentions this issue: cmd/compile: Fix SSA building bug for CAS atomics on ARM64

@dmitshur dmitshur moved this to In Progress in Go Compiler / Runtime May 15, 2024
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. FixPending Issues that have a fix which has not yet been reviewed or submitted. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 15, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Go Compiler / Runtime May 21, 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. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

4 participants