Skip to content

cmd/compile: inline multiplication corrupts an argument on arm #28688

Closed
@frbrno

Description

@frbrno

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

go version go1.11.2 linux/amd64

Does this issue reproduce with the latest release?

YES

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

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fred/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fred/workspace/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build795351668=/tmp/go-build -gno-record-gcc-switches"
### What did you do?
package main

import (
"fmt"
)

func main() {
id := 1
a := float32(2.0)
b := float32(5.0)
testOut(id, a*b)
}

func testOut(id int, a float32) {
fmt.Println(id, a)
}

$ env GOOS=linux GOARCH=arm go build -o test.arm7 main.go

running on raspberry pi 3 Model:B V:2
Linux PiOne 4.14.79-1-ARCH #1 SMP Tue Nov 6 03:01:46 UTC 2018 armv7l GNU/Linux

$ ./test.arm7

What did you expect to see?

1 10

What did you see instead?

1073741824 10

When I do the multiplication outside the function call testOut() I get output (1 10).
Only happens when I do cross compilation.

When I cross compile and set GOARM=7, it works just fine.
env GOOS=linux GOARCH=arm GOARM=7 go build -o test.arm7 main.go

Activity

mvdan

mvdan commented on Nov 9, 2018

@mvdan
Member

@derfbn does this occur with Go 1.10 or previous Go versions?

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Nov 9, 2018
added this to the Go1.12 milestone on Nov 9, 2018
changed the title [-]function call with 2 arguments, inline multiplication corrupts first argument on arm[/-] [+]cmd/compile: inline multiplication corrupts an argument on arm[/+] on Nov 9, 2018
mvdan

mvdan commented on Nov 9, 2018

@mvdan
Member

Tentatively marking as a release blocker for 1.12, until we're sure that this isn't important enough.

frbrno

frbrno commented on Nov 9, 2018

@frbrno
Author

go version go1.10.5 linux/amd64

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fred/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/fred/workspace/go"
GORACE=""
GOROOT="/home/fred/trash/gotest/go1.10.5/go"
GOTMPDIR=""
GOTOOLDIR="/home/fred/trash/gotest/go1.10.5/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build790837178=/tmp/go-build -gno-record-gcc-switches"

@mvdan does not occur on Go 1.10.5

ianlancetaylor

ianlancetaylor commented on Nov 9, 2018

@ianlancetaylor
Contributor
josharian

josharian commented on Nov 9, 2018

@josharian
Contributor

Seems like a backport candidate. Let's wait to see what the diagnosis is.

gopherbot

gopherbot commented on Nov 9, 2018

@gopherbot
Contributor

Change https://golang.org/cl/148837 mentions this issue: cmd/compile/internal/gc: OMUL should be evaluated when using soft-float

milanknezevic

milanknezevic commented on Nov 9, 2018

@milanknezevic
Contributor

The issue can be reproduced on mips too.

josharian

josharian commented on Nov 9, 2018

@josharian
Contributor

@gopherbot please open a backport tracking issue for 1.11. This is a compiler correctness bug.

gopherbot

gopherbot commented on Nov 9, 2018

@gopherbot
Contributor

Backport issue(s) opened: #28694 (for 1.11).

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

milanknezevic

milanknezevic commented on Nov 13, 2018

@milanknezevic
Contributor

@josharian Could this also be backported to 1.10 because it affects mips softfloat support which is added in 1.10?

josharian

josharian commented on Nov 13, 2018

@josharian
Contributor

Sure. FYI, anyone can open a backport request.

@gopherbot please also open a backport tracking issue for 1.10. This is a compiler correctness bug.

josharian

josharian commented on Nov 13, 2018

@josharian
Contributor

Hmm, gopherbot doesn't seem to be as speedy as I would expect. I wonder whether incrementally adding backport releases isn't well supported right now. @dmitshur?

dmitshur

dmitshur commented on Nov 13, 2018

@dmitshur
Member

I wonder whether incrementally adding backport releases isn't well supported right now.

@josharian It's not; the tracking issue for that is #25574. Gopherbot already responded to a backport command earlier in this issue, so until #25574 is resolved, it never listens to follow up backport requests.

Until the gopherbot issue is resolved, the suggested workaround is to create a backport issue manually.

gopherbot

gopherbot commented on Nov 27, 2018

@gopherbot
Contributor

Change https://golang.org/cl/151342 mentions this issue: [release-branch.go1.11] cmd/compile/internal/gc: OMUL should be evaluated when using soft-float

gopherbot

gopherbot commented on Nov 27, 2018

@gopherbot
Contributor

Change https://golang.org/cl/151343 mentions this issue: [release-branch.go1.10] cmd/compile/internal/gc: OMUL should be evaluated when using soft-float

added a commit that references this issue on Nov 30, 2018
gopherbot

gopherbot commented on Dec 14, 2018

@gopherbot
Contributor

Change https://golang.org/cl/154297 mentions this issue: Revert "[release-branch.go1.10] cmd/compile/internal/gc: OMUL should be evaluated when using soft-float"

locked and limited conversation to collaborators on Dec 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.release-blocker

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @josharian@dmitshur@ianlancetaylor@mvdan@frbrno

        Issue actions

          cmd/compile: inline multiplication corrupts an argument on arm · Issue #28688 · golang/go