go: cmd/link: panic: operation not permitted

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?

The issue exists in a family of 1.15.x releases, most probably it relates to linker changes introduced at https://golang.org/doc/go1.15#linker

Previous family of 1.14.x releases are not impacted by the issue

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

go env Output
$ go env

GO111MODULE=“” GOARCH=“amd64” GOBIN=“” GOCACHE=“/tmp” GOENV=“” GOEXE=“” GOFLAGS=“” GOHOSTARCH=“amd64” GOHOSTOS=“linux” GOINSECURE=“” GOMODCACHE=“/tmp/8c7ec6d123a7abf0769333196e0d26f470afdc59/pkg/mod” GONOPROXY=“” GONOSUMDB=“” GOOS=“linux” GOPATH=“/tmp/8c7ec6d123a7abf0769333196e0d26f470afdc59” GOPRIVATE=“” GOPROXY=“https://proxy.golang.org,direct” GOROOT=“/tmp/go” GOSUMDB=“sum.golang.org” GOTMPDIR=“” GOTOOLDIR=“/tmp/go/pkg/tool/linux_amd64” GCCGO=“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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build935346230=/tmp/go-build -gno-record-gcc-switches”

What did you do?

go run hw.go
// hw.go
package main

func main(){}

What did you expect to see?

No error

What did you see instead?

The following command fail at Amazon Linux only while running in the cloud

It fails with

# command-line-arguments
panic: operation not permitted
goroutine 1 [running]:
cmd/link/internal/ld.Main(0x870840, 0x20, 0x20, 0x1, 0x7, 0x10, 0x0, 0x0, 0x6da8ff, 0x1b, ...) | 
/usr/local/go/src/cmd/link/internal/ld/main.go:320 +0x21bd
main.main()
/usr/local/go/src/cmd/link/main.go:68 +0x1dc
...
go run -x hw.go


WORK=/tmp/go-build825787747
mkdir -p $WORK/b001/
cat >$WORK/b001/importcfg << 'EOF' # internal
# import config
packagefile runtime=/tmp/go/pkg/linux_amd64/runtime.a
EOF
cd /tmp
./go/pkg/tool/linux_amd64/compile -o ./go-build825787747/b001/_pkg_.a -trimpath "$WORK/b001=>" -p main -complete -buildid ehL3WBFzOeSpryH7yP9P/ehL3WBFzOeSpryH7yP9P -dwarf=false -goversion go1.15.2 -D _/tmp -importcfg ./go-build825787747/b001/importcfg -pack -c=2 ./test.go
/tmp/go/pkg/tool/linux_amd64/buildid -w $WORK/b001/_pkg_.a # internal
cp $WORK/b001/_pkg_.a /tmp/f8/f806946fd9e5455a99ccbdeaa0e34798d70aed6edb248123b8fd2df38d8bbda3-d # internal
cat >$WORK/b001/importcfg.link << 'EOF' # internal
packagefile command-line-arguments=$WORK/b001/_pkg_.a
packagefile runtime=/tmp/go/pkg/linux_amd64/runtime.a
packagefile internal/bytealg=/tmp/go/pkg/linux_amd64/internal/bytealg.a
packagefile internal/cpu=/tmp/go/pkg/linux_amd64/internal/cpu.a
packagefile runtime/internal/atomic=/tmp/go/pkg/linux_amd64/runtime/internal/atomic.a
packagefile runtime/internal/math=/tmp/go/pkg/linux_amd64/runtime/internal/math.a
packagefile runtime/internal/sys=/tmp/go/pkg/linux_amd64/runtime/internal/sys.a
EOF
mkdir -p $WORK/b001/exe/
cd .
/tmp/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/test -importcfg $WORK/b001/importcfg.link -s -w -buildmode=exe -buildid=Juw7E6kz4zUijtlWIqs0/ehL3WBFzOeSpryH7yP9P/3cKdpLiR9cWyq_AaprQT/Juw7E6kz4zUijtlWIqs0 -extld=gcc $WORK/b001/_pkg_.a

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 25 (16 by maintainers)

Most upvoted comments

@fogfish thanks. I think we have enough information and a proposed solution (https://github.com/golang/go/issues/41356#issuecomment-694992355).