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/go: 'go install -buildmode=shared -linkshared' overwrites files in GOROOT/pkg #28553

Closed
funny-falcon opened this issue Nov 2, 2018 · 8 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@funny-falcon
Copy link
Contributor

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

$ go version
go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

Ubuntu 18.04, go 1.11.1 installed with godep

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/yura/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/yura/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/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-build025854543=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I'm trying to build simplest library in shared mode linked against shared std.

$ sudo rm /usr/local/go/pkg/linux_amd64_dynlink/ -rf
$ sudo rm ~/.cache/go-build/ -rf
$ sudo go install -buildmode=shared std
$ mkdir ~/go/src/mylibrary
$ cat > ~/go/src/mylibrary/lib.go
package mylibrary
import "fmt"
func HelloWorld() {
fmt.Println("Hello World")
}
$ go install -buildmode=shared -linkshared mylibrary
go install runtime/internal/atomic: open /usr/local/go/pkg/linux_amd64_dynlink/runtime/internal/atomic.a: permission denied
go install internal/cpu: open /usr/local/go/pkg/linux_amd64_dynlink/internal/cpu.a: permission denied
go install sync/atomic: open /usr/local/go/pkg/linux_amd64_dynlink/sync/atomic.a: permission denied
go install vendor/golang_org/x/crypto/curve25519: open /usr/local/go/pkg/linux_amd64_dynlink/vendor/golang_org/x/crypto/curve25519.a: permission denied
go install runtime/cgo: open /usr/local/go/pkg/linux_amd64_dynlink/runtime/cgo.a: permission denied
$ sudo go install -buildmode=shared -linkshared sync
$ go install -buildmode=shared -linkshared mylibrary

What did you expect to see?

Compiled shared my library.

What did you see instead?

It never finishes compilation of mylibrary, and eats slowly whole memory of my computer.

@funny-falcon funny-falcon changed the title cmd/link: error with -buildmode=shared: "cannot implicitly include runtime/cgo in a shared library" Could not build shared library linked with shared std Nov 2, 2018
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 4, 2018
@dmitshur dmitshur changed the title Could not build shared library linked with shared std cmd/compile: could not build shared library linked with shared std Nov 4, 2018
@dmitshur dmitshur added this to the Go1.12 milestone Nov 4, 2018
@odeke-em
Copy link
Member

odeke-em commented Dec 9, 2018

Kindly paging @bcmills @randall77 @ianlancetaylor.

@bcmills
Copy link
Contributor

bcmills commented Dec 21, 2018

The bug here is that we're trying to write to /usr/local/go/pkg at all: we should not.

I'm not sure what the fix is, though.

CC @jayconrod

@bcmills bcmills changed the title cmd/compile: could not build shared library linked with shared std cmd/go: 'go install -buildmode=shared -linkshared' overwrites files in GOROOT/pkg Dec 21, 2018
@bcmills bcmills added the GoCommand cmd/go label Dec 21, 2018
@bcmills
Copy link
Contributor

bcmills commented Dec 21, 2018

As a workaround, if you make GOROOT writeable this will probably work. 😕

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Dec 21, 2018
@jayconrod
Copy link
Contributor

I think go install expects to be able to write standard packages into $GOROOT/pkg, not $GOPATH/pkg. So that part at least is working as intended, though perhaps it's worth revisiting that design.

This bit concerns me though:

It never finishes compilation of mylibrary, and eats slowly whole memory of my computer.

I was able to reproduce this in the ubuntu:18.04 docker image by following the repro steps listed above. I installed go1.11.4 manually, and I ran apt-get install build-essential so cgo would work. I ran the sudo commands as root and the other commands as an unprivileged user.

go install went to 100% CPU and took ~1Gb of memory before I killed it. Here's the stack:

PC=0x45b201 m=0 sigcode=0

goroutine 0 [idle]:
runtime.futex(0xd699a0, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7ffe535037d0, 0x40c0b2, ...)
/usr/local/go/src/runtime/sys_linux_amd64.s:531 +0x21
runtime.futexsleep(0xd699a0, 0x7ffe00000000, 0xffffffffffffffff)
/usr/local/go/src/runtime/os_linux.go:46 +0x4b
runtime.notesleep(0xd699a0)
/usr/local/go/src/runtime/lock_futex.go:151 +0xa2
runtime.stopm()
/usr/local/go/src/runtime/proc.go:2016 +0xe3
runtime.findrunnable(0xc000040f00, 0x0)
/usr/local/go/src/runtime/proc.go:2487 +0x4dc
runtime.schedule()
/usr/local/go/src/runtime/proc.go:2613 +0x13a
runtime.park_m(0xc000081200)
/usr/local/go/src/runtime/proc.go:2676 +0xae
runtime.mcall(0x0)
/usr/local/go/src/runtime/asm_amd64.s:299 +0x5b

goroutine 1 [runnable]:
cmd/go/internal/load.PackageList.func1(0xc0002ee000)
/usr/local/go/src/cmd/go/internal/load/pkg.go:1668 +0x1b0
cmd/go/internal/load.PackageList.func1(0xc0000ccd80)
/usr/local/go/src/cmd/go/internal/load/pkg.go:1674 +0xd9
cmd/go/internal/load.PackageList.func1(0xc000545200)
/usr/local/go/src/cmd/go/internal/load/pkg.go:1674 +0xd9
cmd/go/internal/load.PackageList.func1(0xc0003e9680)
/usr/local/go/src/cmd/go/internal/load/pkg.go:1674 +0xd9
cmd/go/internal/load.PackageList(0xc038a727e8, 0x1, 0x1, 0x0, 0x0, 0x0)
/usr/local/go/src/cmd/go/internal/load/pkg.go:1679 +0x111
cmd/go/internal/load.setToolFlags(0xc038a727e8, 0x1, 0x1)
/usr/local/go/src/cmd/go/internal/load/pkg.go:1878 +0x43
cmd/go/internal/load.LoadPackage(0xc01bd74a40, 0x11, 0xc038a728d0, 0x9fd)
/usr/local/go/src/cmd/go/internal/load/pkg.go:1731 +0x77
cmd/go/internal/work.readpkglist(0xc00032f9b0, 0x2f, 0x7f409ffb9db0, 0xc038a72a40, 0x446c2f)
/usr/local/go/src/cmd/go/internal/work/action.go:301 +0x29c
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:663 +0x5ae
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bd745e0, 0x15, 0x0, 0xc033494640, 0xc01bd745e0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03eb48f00, 0xc03eb48dc0, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bd742c0, 0x16, 0x0, 0xc0334945f0, 0xc01bd742c0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03eb48b40, 0xc03eb48a00, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bf91a00, 0x15, 0x0, 0xc033494550, 0xc01bf91a00)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03eb488c0, 0xc03eb48780, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bf918a0, 0x16, 0x0, 0xc033494500, 0xc01bf918a0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03eb48500, 0xc03eb483c0, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bf90ea0, 0x15, 0x0, 0xc033494460, 0xc01bf90ea0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03eb48280, 0xc03eb48140, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bf90d40, 0x16, 0x0, 0xc033494410, 0xc01bf90d40)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580be00, 0xc03580bcc0, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bf90480, 0x15, 0x0, 0xc033494370, 0xc01bf90480)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580bb80, 0xc03580ba40, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc01bf901a0, 0x16, 0x0, 0xc033494320, 0xc01bf901a0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580b7c0, 0xc03580b680, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03e967920, 0x15, 0x0, 0xc033494280, 0xc03e967920)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580b540, 0xc03580b400, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03e967840, 0x16, 0x0, 0xc033494230, 0xc03e967840)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580b180, 0xc03580b040, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03e967000, 0x15, 0x0, 0xc033494190, 0xc03e967000)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580af00, 0xc03580adc0, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03e966f20, 0x16, 0x0, 0xc033494140, 0xc03e966f20)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580ab40, 0xc03580aa00, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03e966660, 0x15, 0x0, 0xc0334940a0, 0xc03e966660)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580a8c0, 0xc03580a780, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03e9664c0, 0x16, 0x0, 0xc033494050, 0xc03e9664c0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580a500, 0xc03580a3c0, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc033dddb80, 0x15, 0x0, 0xc02a7b7f90, 0xc033dddb80)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc03580a280, 0xc03580a140, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc033ddda60, 0x16, 0x0, 0xc02a7b7f40, 0xc033ddda60)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7ffe00, 0xc02b7ffcc0, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc033ddd1e0, 0x15, 0x0, 0xc02a7b7ea0, 0xc033ddd1e0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7ffb80, 0xc02b7ffa40, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc033ddd0c0, 0x16, 0x0, 0xc02a7b7e50, 0xc033ddd0c0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7ff7c0, 0xc02b7ff680, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc033ddc7c0, 0x15, 0x0, 0xc02a7b7db0, 0xc033ddc7c0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7ff540, 0xc02b7ff400, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc033ddc6a0, 0x16, 0x0, 0xc02a7b7d60, 0xc033ddc6a0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7ff180, 0xc02b7ff040, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03f051ee0, 0x15, 0x0, 0xc02a7b7cc0, 0xc03f051ee0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7fef00, 0xc02b7fedc0, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03f051dc0, 0x16, 0x0, 0xc02a7b7c70, 0xc03f051dc0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032e150, 0x30, 0x0, 0x80)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7feb40, 0xc02b7fea00, 0xc00032f9d6, 0x9)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
cmd/go/internal/work.(*Builder).linkSharedAction.func1(0x8eea20)
/usr/local/go/src/cmd/go/internal/work/action.go:730 +0x463
cmd/go/internal/work.(*Builder).cacheAction(0xc0001f3720, 0xc03f0514c0, 0x15, 0x0, 0xc02a7b7bd0, 0xc03f0514c0)
/usr/local/go/src/cmd/go/internal/work/action.go:314 +0xa7
cmd/go/internal/work.(*Builder).linkSharedAction(0xc0001f3720, 0x2, 0x2, 0xc00032f9b0, 0x2f, 0x0, 0x8)
/usr/local/go/src/cmd/go/internal/work/action.go:659 +0x185
cmd/go/internal/work.(*Builder).addTransitiveLinkDeps(0xc0001f3720, 0xc02b7fe8c0, 0xc02b7fe780, 0xc00032e176, 0xa)
/usr/local/go/src/cmd/go/internal/work/action.go:608 +0x620
...additional frames elided...

goroutine 19 [syscall, 1 minutes]:
os/signal.signal_recv(0x0)
/usr/local/go/src/runtime/sigqueue.go:139 +0x9c
os/signal.loop()
/usr/local/go/src/os/signal/signal_unix.go:23 +0x22
created by os/signal.init.0
/usr/local/go/src/os/signal/signal_unix.go:29 +0x41

rax 0xca
rbx 0xd69860
rcx 0x45b203
rdx 0x0
rdi 0xd699a0
rsi 0x80
rbp 0x7ffe53503798
rsp 0x7ffe53503750
r8 0x0
r9 0x0
r10 0x0
r11 0x286
r12 0xff
r13 0x3
r14 0xc000476700
r15 0x0
rip 0x45b201
rflags 0x286
cs 0x33
fs 0x0
gs 0x0

[1]+ Exit 2 go install -buildmode=shared -linkshared mylibrary

@jayconrod jayconrod self-assigned this Dec 21, 2018
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/208482 mentions this issue: misc/cgo/testshared: do not write to GOROOT

gopherbot pushed a commit that referenced this issue Nov 25, 2019
Instead of installing shared libraries to GOROOT/pkg, clone the
necessary files into a new GOROOT and run there.

Given that we now have a build cache, ideally we should not need to
install into GOROOT/pkg at all, but we can't fix that during the 1.14
code freeze.

Updates #28387
Updates #28553
Updates #30316

Change-Id: I83084a8ca29a5dffcd586c7fccc3f172cac57cc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/208482
Run-TryBot: Bryan C. Mills <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
@diamondburned
Copy link

I'm not sure what the fix is, though.

How reasonable would it be to have Go write to $GOPATH instead as a fallback? It can then check both $GOROOT and $GOPATH in that order.

@xandris
Copy link

xandris commented Aug 18, 2021

How about if it's trying to write the same value to the file as what's in the file (libstd.so), don't try to do the write?

@jayconrod
Copy link
Contributor

Obsoleted by #47788

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

10 participants