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/addr2line: TestAddr2Line fails with double / in $GOROOT_FINAL #41447

Closed
navytux opened this issue Sep 17, 2020 · 8 comments
Closed

cmd/addr2line: TestAddr2Line fails with double / in $GOROOT_FINAL #41447

navytux opened this issue Sep 17, 2020 · 8 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@navytux
Copy link
Contributor

navytux commented Sep 17, 2020

Hello up there. While trying to update SlapOS to use Go1.15 I've hit a bug where Go fails to install from source in case when $GOROOT_FINAL has an extra slash inside. It used to work correctly before. Commit cacac8b (CL 236819) is likely the cause.

Even though in simple cases it is easy to workaround the issue by feeding $GOROOT_FINAL with only clean and normalized file paths, in practice in SlapOS context it is not always easily possible.

Please find details below.

Thanks beforehand,
Kirill

/cc @bcmills

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

$ go version
go version go1.15.2 linux/amd64

Does this issue reproduce with the latest release?

No, it works ok with Go1.14 and other previous Go releases. It is 1.15 regression.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/kirr/.cache/go-build"
GOENV="/home/kirr/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/kirr/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/kirr/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/kirr/tmp/trashme/go115-try/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/kirr/tmp/trashme/go115-try/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
AR="ar"
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-build138948010=/tmp/go-build -gno-record-gcc-switches"
uname -sr: Linux 5.8.0-1-amd64
Distributor ID:	Debian
Description:	Debian GNU/Linux bullseye/sid
Release:	testing
Codename:	bullseye
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Debian GLIBC 2.31-3) stable release version 2.31.
gdb --version: GNU gdb (Debian 9.2-1) 9.2

What did you do?

  • download go1.15.2.src.tar.gz, unpack it
  • create gofinal/
  • set $GOROOT_BOOTSTRAP
  • set $GOROOT_FINAL with double // inside
  • cd go/src/ && ./all.bash

( Please see full tanscript with all details below )

What did you expect to see?

Everything compiles ok; tests run fine.

What did you see instead?

--- FAIL: TestAddr2Line (2.58s)
    addr2line_test.go:88: Stat failed: stat /home/kirr/tmp/trashme/go115-try/gofinal/src/cmd/addr2line/addr2line_test.go: no such file or directory
FAIL
full transcript
kirr@deco:~/tmp/trashme/go115-try$ wget https://golang.org/dl/go1.15.2.src.tar.gz
--2020-09-17 14:12:17--  https://golang.org/dl/go1.15.2.src.tar.gz
Распознаётся golang.org (golang.org)… 173.194.73.141, 2a00:1450:4010:c0d::8d
Подключение к golang.org (golang.org)|173.194.73.141|:443... соединение установлено.
HTTP-запрос отправлен. Ожидание ответа… 302 Found
Адрес: https://dl.google.com/go/go1.15.2.src.tar.gz [переход]
--2020-09-17 14:12:17--  https://dl.google.com/go/go1.15.2.src.tar.gz
Распознаётся dl.google.com (dl.google.com)… 64.233.164.91, 64.233.164.93, 64.233.164.136, ...
Подключение к dl.google.com (dl.google.com)|64.233.164.91|:443... соединение установлено.
HTTP-запрос отправлен. Ожидание ответа… 200 OK
Длина: 23012667 (22M) [application/octet-stream]
Сохранение в: «go1.15.2.src.tar.gz»

go1.15.2.src.tar.gz 100%[===================>]  21,95M  24,7MB/s    за 0,9s    

2020-09-17 14:12:18 (24,7 MB/s) - «go1.15.2.src.tar.gz» сохранён [23012667/23012667]

kirr@deco:~/tmp/trashme/go115-try$ sha256sum go1.15.2.src.tar.gz 
28bf9d0bcde251011caae230a4a05d917b172ea203f2a62f2c2f9533589d4b4d  go1.15.2.src.tar.gz
kirr@deco:~/tmp/trashme/go115-try$ tar xfz go1.15.2.src.tar.gz 
kirr@deco:~/tmp/trashme/go115-try$ mkdir gofinal
kirr@deco:~/tmp/trashme/go115-try$ ll
итого 22488
drwxr-xr-x 8 kirr kirr     4096 сен  9 19:58 go
-rw-r--r-- 1 kirr kirr 23012667 сен  9 23:09 go1.15.2.src.tar.gz
drwxr-xr-x 2 kirr kirr     4096 сен 17 14:13 gofinal
kirr@deco:~/tmp/trashme/go115-try$ export GOROOT_BOOTSTRAP=$HOME/src/tools/go/go14/
kirr@deco:~/tmp/trashme/go115-try$ export GOROOT_FINAL=`pwd`//gofinal # notice doble /
kirr@deco:~/tmp/trashme/go115-try$ echo $GOROOT_FINAL 
/home/kirr/tmp/trashme/go115-try//gofinal
kirr@deco:~/tmp/trashme/go115-try$ cd go/src/
kirr@deco:~/tmp/trashme/go115-try/go/src$ ./all.bash 
Building Go cmd/dist using /home/kirr/src/tools/go/go14/. (go1.4-bootstrap-20170531 linux/amd64)
Building Go toolchain1 using /home/kirr/src/tools/go/go14/.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.

##### Testing packages.
ok      archive/tar     0.037s
ok      archive/zip     0.076s
ok      bufio   0.068s
ok      bytes   0.384s
ok      compress/bzip2  0.063s
ok      compress/flate  0.847s
ok      compress/gzip   0.024s
ok      compress/lzw    0.006s
ok      compress/zlib   0.028s
ok      container/heap  0.020s
ok      container/list  0.009s
ok      container/ring  0.002s
ok      context 0.012s
ok      crypto  0.009s
ok      crypto/aes      0.041s
ok      crypto/cipher   0.007s
ok      crypto/des      0.048s
ok      crypto/dsa      0.017s
ok      crypto/ecdsa    0.223s
ok      crypto/ed25519  0.104s
ok      crypto/elliptic 0.060s
ok      crypto/hmac     0.047s
ok      crypto/internal/subtle  0.016s
ok      crypto/md5      0.005s
ok      crypto/rand     0.020s
ok      crypto/rc4      0.043s
ok      crypto/rsa      0.139s
ok      crypto/sha1     0.030s
ok      crypto/sha256   0.007s
ok      crypto/sha512   0.016s
ok      crypto/subtle   0.006s
ok      crypto/tls      1.071s
ok      crypto/x509     0.542s
ok      database/sql    0.694s
ok      database/sql/driver     0.012s
ok      debug/dwarf     0.010s
ok      debug/elf       0.031s
ok      debug/gosym     0.005s
ok      debug/macho     0.003s
ok      debug/pe        0.023s
ok      debug/plan9obj  0.010s
ok      encoding/ascii85        0.050s
ok      encoding/asn1   0.007s
ok      encoding/base32 0.015s
ok      encoding/base64 0.009s
ok      encoding/binary 0.035s
ok      encoding/csv    0.011s
ok      encoding/gob    0.034s
ok      encoding/hex    0.043s
ok      encoding/json   0.227s
ok      encoding/pem    0.013s
ok      encoding/xml    0.023s
ok      errors  0.003s
ok      expvar  0.009s
ok      flag    0.149s
ok      fmt     0.145s
ok      go/ast  0.003s
ok      go/build        1.431s
ok      go/constant     0.022s
ok      go/doc  0.048s
ok      go/format       0.006s
ok      go/importer     0.088s
ok      go/internal/gccgoimporter       1.554s
ok      go/internal/gcimporter  0.463s
ok      go/internal/srcimporter 6.630s
ok      go/parser       0.040s
ok      go/printer      0.297s
ok      go/scanner      0.020s
ok      go/token        0.065s
ok      go/types        0.835s
ok      hash    0.017s
ok      hash/adler32    0.009s
ok      hash/crc32      0.005s
ok      hash/crc64      0.048s
ok      hash/fnv        0.002s
ok      hash/maphash    0.074s
ok      html    0.031s
ok      html/template   0.096s
ok      image   0.100s
ok      image/color     0.033s
ok      image/draw      0.052s
ok      image/gif       0.415s
ok      image/jpeg      0.295s
ok      image/png       0.039s
ok      index/suffixarray       0.237s
ok      internal/cpu    0.075s
ok      internal/fmtsort        0.002s
ok      internal/poll   0.061s
ok      internal/profile        0.004s
ok      internal/reflectlite    0.089s
ok      internal/singleflight   0.048s
ok      internal/trace  0.055s
ok      internal/unsafeheader   0.039s
ok      internal/xcoff  0.020s
ok      io      0.040s
ok      io/ioutil       0.012s
ok      log     0.019s
ok      log/syslog      1.229s
ok      math    0.010s
ok      math/big        1.596s
ok      math/bits       0.010s
ok      math/cmplx      0.011s
ok      math/rand       0.163s
ok      mime    0.012s
ok      mime/multipart  0.240s
ok      mime/quotedprintable    0.012s
ok      net     4.344s
ok      net/http        9.780s
ok      net/http/cgi    0.674s
ok      net/http/cookiejar      0.028s
ok      net/http/fcgi   0.046s
ok      net/http/httptest       0.033s
ok      net/http/httptrace      0.043s
ok      net/http/httputil       0.073s
ok      net/http/internal       0.006s
ok      net/http/pprof  5.105s
ok      net/internal/socktest   0.001s
ok      net/mail        0.003s
ok      net/rpc 0.032s
ok      net/rpc/jsonrpc 0.004s
ok      net/smtp        0.017s
ok      net/textproto   0.003s
ok      net/url 0.005s
ok      os      0.957s
ok      os/exec 1.173s
ok      os/signal       2.339s
ok      os/user 0.011s
ok      path    0.003s
ok      path/filepath   0.009s
ok      plugin  0.034s
ok      reflect 0.294s
ok      regexp  0.085s
ok      regexp/syntax   0.559s
ok      runtime 73.731s
ok      runtime/debug   0.055s
ok      runtime/internal/atomic 0.035s
ok      runtime/internal/math   0.023s
ok      runtime/internal/sys    0.026s
ok      runtime/pprof   6.084s
ok      runtime/race    0.198s
ok      runtime/trace   0.735s
ok      sort    0.077s
ok      strconv 0.558s
ok      strings 0.157s
ok      sync    0.435s
ok      sync/atomic     0.081s
ok      syscall 0.085s
ok      testing 0.279s
ok      testing/iotest  0.029s
ok      testing/quick   0.052s
ok      text/scanner    0.024s
ok      text/tabwriter  0.009s
ok      text/template   0.089s
ok      text/template/parse     0.007s
ok      time    1.868s
ok      unicode 0.025s
ok      unicode/utf16   0.002s
ok      unicode/utf8    0.015s
--- FAIL: TestAddr2Line (2.58s)
    addr2line_test.go:88: Stat failed: stat /home/kirr/tmp/trashme/go115-try/gofinal/src/cmd/addr2line/addr2line_test.go: no such file or directory
FAIL
FAIL    cmd/addr2line   2.591s
ok      cmd/api 7.529s
ok      cmd/asm/internal/asm    1.626s
ok      cmd/asm/internal/lex    0.037s
ok      cmd/compile     0.033s
ok      cmd/compile/internal/gc 11.223s
ok      cmd/compile/internal/logopt     0.330s
ok      cmd/compile/internal/ssa        1.007s
ok      cmd/compile/internal/syntax     0.071s
ok      cmd/compile/internal/test       0.030s [no tests to run]
ok      cmd/compile/internal/types      0.009s
ok      cmd/cover       3.016s
ok      cmd/doc 0.232s
ok      cmd/fix 2.943s
ok      cmd/go  50.228s
ok      cmd/go/internal/auth    0.028s
ok      cmd/go/internal/cache   0.114s
ok      cmd/go/internal/generate        0.011s
ok      cmd/go/internal/get     0.014s
ok      cmd/go/internal/imports 0.029s
ok      cmd/go/internal/load    0.015s
ok      cmd/go/internal/lockedfile      0.152s
ok      cmd/go/internal/lockedfile/internal/filelock    0.110s
ok      cmd/go/internal/modconv 0.021s
ok      cmd/go/internal/modfetch        0.008s
ok      cmd/go/internal/modfetch/codehost       0.008s
ok      cmd/go/internal/modfetch/zip_sum_test   0.021s
ok      cmd/go/internal/modload 0.027s
ok      cmd/go/internal/mvs     0.038s
ok      cmd/go/internal/par     0.050s
ok      cmd/go/internal/renameio        0.073s
ok      cmd/go/internal/search  0.025s
ok      cmd/go/internal/test    0.053s
ok      cmd/go/internal/txtar   0.018s
ok      cmd/go/internal/web     0.024s
ok      cmd/go/internal/work    0.035s
ok      cmd/gofmt       0.121s
ok      cmd/internal/buildid    0.434s
ok      cmd/internal/dwarf      0.031s
ok      cmd/internal/edit       0.039s
ok      cmd/internal/goobj      1.502s
ok      cmd/internal/goobj2     0.039s
ok      cmd/internal/moddeps    2.524s
ok      cmd/internal/obj        0.019s
ok      cmd/internal/obj/arm64  0.147s
ok      cmd/internal/obj/ppc64  0.128s
ok      cmd/internal/obj/riscv  0.115s
ok      cmd/internal/obj/x86    0.712s
ok      cmd/internal/objabi     0.017s
ok      cmd/internal/src        0.058s
ok      cmd/internal/test2json  0.269s
ok      cmd/link        20.705s
ok      cmd/link/internal/benchmark     0.020s
ok      cmd/link/internal/ld    4.689s
ok      cmd/link/internal/loader        0.046s
ok      cmd/link/internal/sym   0.029s
ok      cmd/nm  4.621s
ok      cmd/objdump     3.364s
ok      cmd/oldlink/internal/sym        0.017s
ok      cmd/pack        2.136s
ok      cmd/trace       0.090s
ok      cmd/vet 11.152s
FAIL
go tool dist: Failed: exit status 1
@bcmills bcmills changed the title go1.15.2 fails to install with double / in $GOROOT_FINAL cmd/addr2line: TestAddr2Line fails with double / in $GOROOT_FINAL Sep 17, 2020
@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure. labels Sep 17, 2020
@bcmills bcmills self-assigned this Sep 17, 2020
@bcmills bcmills added this to the Go1.16 milestone Sep 17, 2020
@bcmills
Copy link
Contributor

bcmills commented Sep 17, 2020

I can get you a patch for this, but just to set expectations: this is a test-only fix that can be avoided by using a clean path in GOROOT_FINAL in the first place, so I don't think it's worth backporting to the 1.15 release branch.

@gopherbot
Copy link

Change https://golang.org/cl/255477 mentions this issue: cmd/addr2line: don't assume that GOROOT_FINAL is clean

@navytux
Copy link
Contributor Author

navytux commented Sep 17, 2020

@bcmills, thanks for the patch - I confirm it fixes the problem. I partly share you view on the expectations - before reporting I was wondering myself where the bug is - e.g. "is it the mistake on user side? or on go side?", because, indeed, feeding unclean path feels somewhat not good. However my final understanding is that:

  • even if the path is unclean, it is still correct for a user to set $GOROOT_FINAL to it, becuase
  • the semantic of $GOROOT_FINAL is that it is where final build result will be copied to after running full all.bash in original source tree. The uncleannes of $GOROOT_FINAL does not prevent the copy nor future operation in any way
  • this means the behaviour to correct is on the Go side in the first place
  • the issue actually happens in production build of Go in SlapOS profile
  • SlapOS profile for Go used to work for Go versions <= 1.14 and started to break - due to the hereby reported issue - with Go1.15

Unfortunately, as I wrote in original report, even if it might seem a bit surprising, it is not easy to fix the cleannes issue on SlapOS side, where multiple layers - not every of which is in control of author of final application profile - add those // into inside the path.

Since it is 1.14 -> 1.15 regression caught for real in practice, and the fix is test only - i.e. the fix is very likely risk free - I still suggest to backport the patch into Go 1.15 as well.

Kirill

@bcmills

This comment has been minimized.

@gopherbot
Copy link

gopherbot commented Sep 17, 2020

Backport issue(s) opened: #41453 (for 1.15).

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

@bcmills
Copy link
Contributor

bcmills commented Sep 17, 2020

@gopherbot, please backport to 1.15. See rationale in #41447 (comment).

@navytux
Copy link
Contributor Author

navytux commented Sep 17, 2020

Thanks

@gopherbot
Copy link

Change https://golang.org/cl/255658 mentions this issue: [release-branch.go1.15] cmd/addr2line: don't assume that GOROOT_FINAL is clean

gopherbot pushed a commit that referenced this issue Oct 6, 2020
… is clean

Updates #41447
Fixes #41453

Change-Id: I4460c1c7962d02c41622a5ea1a3c4bc3714a1873
Reviewed-on: https://go-review.googlesource.com/c/go/+/255477
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 6796a7f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/255658
claucece pushed a commit to claucece/go that referenced this issue Oct 22, 2020
… is clean

Updates golang#41447
Fixes golang#41453

Change-Id: I4460c1c7962d02c41622a5ea1a3c4bc3714a1873
Reviewed-on: https://go-review.googlesource.com/c/go/+/255477
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 6796a7f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/255658
@golang golang locked and limited conversation to collaborators Sep 17, 2021
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

3 participants