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/buildid: rewrite algorithm is broken #23181

Closed
hirochachacha opened this issue Dec 19, 2017 · 1 comment
Closed

cmd/buildid: rewrite algorithm is broken #23181

hirochachacha opened this issue Dec 19, 2017 · 1 comment
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@hirochachacha
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

Apply following patch

diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index b3fb5dce4f..b7b2d6ca9e 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -4778,7 +4778,7 @@ func TestExecBuildX(t *testing.T) {
        obj := tg.path("main")
        tg.run("build", "-x", "-o", obj, src)
        sh := tg.path("test.sh")
-       err := ioutil.WriteFile(sh, []byte(tg.getStderr()), 0666)
+       err := ioutil.WriteFile(sh, []byte("set -e\n"+tg.getStderr()), 0666)
        if err != nil {
                t.Fatal(err)
        }

Then do go test cmd/go -run ExecBuildX

What did you expect to see?

success.

What did you see instead?

--- FAIL: TestExecBuildX (1.58s)
	go_test.go:4779: running testgo [build -x -o /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772/main /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772/main.go]
	go_test.go:4779: standard error:
	go_test.go:4779: WORK=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917
		mkdir -p $WORK/b001/
		cd /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772
		CGO_LDFLAGS='"-g" "-O2"' /Users/hiro/go/pkg/tool/darwin_amd64/cgo -objdir $WORK/b001/ -importpath command-line-arguments -- -I $WORK/b001/ -g -O2 ./main.go
		cd $WORK
		clang -fno-caret-diagnostics -c -x c -
		clang -Qunused-arguments -c -x c -
		clang -fdebug-prefix-map=a=b -c -x c -
		clang -gno-record-gcc-switches -c -x c -
		cd $WORK/b001
		clang -I /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -o ./_x001.o -c _cgo_export.c
		clang -I /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -o ./_x002.o -c main.cgo2.c
		clang -I /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -o ./_cgo_main.o -c _cgo_main.c
		cd /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772
		clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -o $WORK/b001/_cgo_.o $WORK/b001/_cgo_main.o $WORK/b001/_x001.o $WORK/b001/_x002.o -g -O2
		/Users/hiro/go/pkg/tool/darwin_amd64/cgo -dynpackage main -dynimport $WORK/b001/_cgo_.o -dynout $WORK/b001/_cgo_import.go
		cat >$WORK/b001/importcfg << 'EOF' # internal
		packagefile runtime/cgo=/Users/hiro/go/pkg/darwin_amd64/runtime/cgo.a
		packagefile syscall=/Users/hiro/go/pkg/darwin_amd64/syscall.a
		packagefile runtime=/Users/hiro/go/pkg/darwin_amd64/runtime.a
		EOF
		/Users/hiro/go/pkg/tool/darwin_amd64/compile -o $WORK/b001/_pkg_.a -trimpath $WORK/b001 -p main -buildid Pvia30_ZJ2bZjjpdCraT/Pvia30_ZJ2bZjjpdCraT -D _/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -importcfg $WORK/b001/importcfg -pack -c=4 $WORK/b001/_cgo_gotypes.go $WORK/b001/main.cgo1.go $WORK/b001/_cgo_import.go
		/Users/hiro/go/pkg/tool/darwin_amd64/pack r $WORK/b001/_pkg_.a $WORK/b001/_x001.o $WORK/b001/_x002.o # internal
		/Users/hiro/go/pkg/tool/darwin_amd64/buildid -w $WORK/b001/_pkg_.a # internal
		cat >$WORK/b001/importcfg.link << 'EOF' # internal
		packagefile command-line-arguments=$WORK/b001/_pkg_.a
		packagefile runtime/cgo=/Users/hiro/go/pkg/darwin_amd64/runtime/cgo.a
		packagefile syscall=/Users/hiro/go/pkg/darwin_amd64/syscall.a
		packagefile runtime=/Users/hiro/go/pkg/darwin_amd64/runtime.a
		packagefile errors=/Users/hiro/go/pkg/darwin_amd64/errors.a
		packagefile internal/race=/Users/hiro/go/pkg/darwin_amd64/internal/race.a
		packagefile sync=/Users/hiro/go/pkg/darwin_amd64/sync.a
		packagefile runtime/internal/atomic=/Users/hiro/go/pkg/darwin_amd64/runtime/internal/atomic.a
		packagefile runtime/internal/sys=/Users/hiro/go/pkg/darwin_amd64/runtime/internal/sys.a
		packagefile sync/atomic=/Users/hiro/go/pkg/darwin_amd64/sync/atomic.a
		EOF
		mkdir -p $WORK/b001/exe/
		cd .
		/Users/hiro/go/pkg/tool/darwin_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -buildmode=exe -buildid=lGCMRh64N-AmvCfVPDjP/Pvia30_ZJ2bZjjpdCraT/seVJRUY_34hGdCfHJrh7/lGCMRh64N-AmvCfVPDjP -extld=clang $WORK/b001/_pkg_.a
		/Users/hiro/go/pkg/tool/darwin_amd64/buildid -w $WORK/b001/exe/a.out # internal
		mkdir -p /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772/
		mv $WORK/b001/exe/a.out /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772/main
		rm -r $WORK/b001/

	go_test.go:4801: /bin/sh /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772/test.sh: exit status 1
		+ set -e
		+ WORK=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917
		+ mkdir -p /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/
		+ cd /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772
		+ CGO_LDFLAGS='"-g" "-O2"'
		+ /Users/hiro/go/pkg/tool/darwin_amd64/cgo -objdir /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/ -importpath command-line-arguments -- -I /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/ -g -O2 ./main.go
		+ cd /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917
		+ clang -fno-caret-diagnostics -c -x c -
		+ clang -Qunused-arguments -c -x c -
		+ clang -fdebug-prefix-map=a=b -c -x c -
		+ clang -gno-record-gcc-switches -c -x c -
		+ cd /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001
		+ clang -I /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -o ./_x001.o -c _cgo_export.c
		+ clang -I /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -o ./_x002.o -c main.cgo2.c
		+ clang -I /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -I ./ -g -O2 -o ./_cgo_main.o -c _cgo_main.c
		+ cd /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772
		+ clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001=/tmp/go-build -gno-record-gcc-switches -fno-common -o /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_cgo_.o /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_cgo_main.o /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_x001.o /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_x002.o -g -O2
		+ /Users/hiro/go/pkg/tool/darwin_amd64/cgo -dynpackage main -dynimport /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_cgo_.o -dynout /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_cgo_import.go
		+ cat
		+ /Users/hiro/go/pkg/tool/darwin_amd64/compile -o /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_pkg_.a -trimpath /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001 -p main -buildid Pvia30_ZJ2bZjjpdCraT/Pvia30_ZJ2bZjjpdCraT -D _/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/gotest098075772 -importcfg /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/importcfg -pack -c=4 /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_cgo_gotypes.go /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/main.cgo1.go /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_cgo_import.go
		+ /Users/hiro/go/pkg/tool/darwin_amd64/pack r /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_pkg_.a /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_x001.o /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_x002.o
		+ /Users/hiro/go/pkg/tool/darwin_amd64/buildid -w /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_pkg_.a
		buildid: /var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build213127917/b001/_pkg_.a: cannot find 32-byte hash in id Pvia30_ZJ2bZjjpdCraT/Pvia30_ZJ2bZjjpdCraT
FAIL
FAIL	cmd/go	2.943s

Does this issue reproduce with the latest release (go1.9.2)?

System details

go version devel +3aeb3950a9 Mon Dec 18 20:24:12 2017 +0000 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hiro/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hiro/.go"
GORACE=""
GOROOT="/Users/hiro/go"
GOTMPDIR=""
GOTOOLDIR="/Users/hiro/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build018883550=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel +3aeb3950a9 Mon Dec 18 20:24:12 2017 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel +3aeb3950a9 Mon Dec 18 20:24:12 2017 +0000
uname -v: Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.13.2
BuildVersion:	17C88
lldb --version: lldb-900.0.64
  Swift-4.0
gdb --version: GNU gdb (GDB) 8.0.1

This happens because cmd/buildid doesn't implement the same algorithm as cmd/go/internal/work/buildid.go:updateBuildID

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/84735 mentions this issue: cmd/buildid: fix rewrite algorithm

@bradfitz bradfitz added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker labels Dec 19, 2017
@bradfitz bradfitz added this to the Go1.10 milestone Dec 19, 2017
@golang golang locked and limited conversation to collaborators Jan 4, 2019
@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants