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

runtime: "forcegc: phase error" running program using plugin on Darwin #63151

Closed
laplantePierre opened this issue Sep 21, 2023 · 7 comments
Closed
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@laplantePierre
Copy link

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

$ go version
go version go1.21.1 darwin/arm64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/laplante/Library/Caches/go-build'
GOENV='/Users/laplante/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/laplante/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/laplante/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/laplante/go/src/my_main/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/97/bpckjl355hd7gprlpdk_zv4m0000gn/T/go-build4196137683=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I have a main program:

package main

import "plugin"

func main() {
p, err := plugin.Open("../my_plugin/my_plugin.so")
if err != nil {
panic(err)
}
v, err := p.Lookup("V")
if err != nil {
panic(err)
}
f, err := p.Lookup("F")
if err != nil {
panic(err)
}
*v.(*int) = 7
f.(func())() // prints "Hello, number 7"
}

I have a my_plugin program:

package main

import "fmt"

var V int

func F() { fmt.Printf("Hello, number %d\n", V) }

What did you expect to see?

When I compile and run main program panics:

I expect a normal output. It was working but I don,t know if its the update of macos or the update of go to 1.21.1

What did you see instead?

fatal error: forcegc: phase error

goroutine 18 [running]:
runtime.throw({0x14c1c5c52?, 0x104e86f10?})
/usr/local/go/src/runtime/panic.go:1077 +0x40 fp=0x14000046790 sp=0x14000046760 pc=0x14c12a9e0
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:319 +0x114 fp=0x140000467d0 sp=0x14000046790 pc=0x14c12dd64
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000467d0 sp=0x140000467d0 pc=0x14c157164
created by runtime.init.6 in goroutine 1
/usr/local/go/src/runtime/proc.go:310 +0x24

goroutine 1 [runnable]:
os.init()
/usr/local/go/src/os/dir.go:108 +0x430 fp=0x140000c3ad0 sp=0x140000c3ad0 pc=0x14c1b6a90
runtime.doInit1(0x14c2c7c20)
/usr/local/go/src/runtime/proc.go:6740 +0xd4 fp=0x140000c3c00 sp=0x140000c3ad0 pc=0x104dc76f4
runtime.doInit({0x14c2c7ee0, 0xa, 0x140000a8000?})
/usr/local/go/src/runtime/proc.go:6707 +0x38 fp=0x140000c3c20 sp=0x140000c3c00 pc=0x104dc75d8
plugin.open({0x104df0f84, 0x19})
/usr/local/go/src/plugin/plugin_dlopen.go:95 +0x520 fp=0x140000c3ea0 sp=0x140000c3c20 pc=0x104decfe0
plugin.Open(...)
/usr/local/go/src/plugin/plugin.go:80
main.main()
/Users/laplante/go/src/my_main/main.go:6 +0x30 fp=0x140000c3f30 sp=0x140000c3ea0 pc=0x104ded710
runtime.main()
/usr/local/go/src/runtime/proc.go:267 +0x2bc fp=0x140000c3fd0 sp=0x140000c3f30 pc=0x104db9a8c
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000c3fd0 sp=0x140000c3fd0 pc=0x104de1ac4

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:398 +0xc8 fp=0x14000046f90 sp=0x14000046f70 pc=0x104db9eb8
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:404
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:322 +0xb8 fp=0x14000046fd0 sp=0x14000046f90 pc=0x104db9d48
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000046fd0 sp=0x14000046fd0 pc=0x104de1ac4
created by runtime.init.6 in goroutine 1
/usr/local/go/src/runtime/proc.go:310 +0x24

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:398 +0xc8 fp=0x14000047760 sp=0x14000047740 pc=0x104db9eb8
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:404
runtime.bgsweep(0x0?)
/usr/local/go/src/runtime/mgcsweep.go:280 +0xa0 fp=0x140000477b0 sp=0x14000047760 pc=0x104da5ad0
runtime.gcenable.func1()
/usr/local/go/src/runtime/mgc.go:200 +0x28 fp=0x140000477d0 sp=0x140000477b0 pc=0x104d9a698
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x140000477d0 sp=0x140000477d0 pc=0x104de1ac4
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:200 +0x6c

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x14000070000?, 0x104e09eb0?, 0x1?, 0x0?, 0x140000031e0?)
/usr/local/go/src/runtime/proc.go:398 +0xc8 fp=0x14000047f50 sp=0x14000047f30 pc=0x104db9eb8
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:404
runtime.(*scavengerState).park(0x104e883c0)
/usr/local/go/src/runtime/mgcscavenge.go:425 +0x5c fp=0x14000047f80 sp=0x14000047f50 pc=0x104da31dc
runtime.bgscavenge(0x0?)
/usr/local/go/src/runtime/mgcscavenge.go:653 +0x44 fp=0x14000047fb0 sp=0x14000047f80 pc=0x104da3754
runtime.gcenable.func2()
/usr/local/go/src/runtime/mgc.go:201 +0x28 fp=0x14000047fd0 sp=0x14000047fb0 pc=0x104d9a638
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1197 +0x4 fp=0x14000047fd0 sp=0x14000047fd0 pc=0x104de1ac4
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:201 +0xac

@ianlancetaylor ianlancetaylor changed the title affected/package: plugin runtime: "forcegc: phase error" running program using plugin on Darwin Sep 21, 2023
@ianlancetaylor ianlancetaylor added OS-Darwin NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 21, 2023
@ianlancetaylor
Copy link
Contributor

CC @golang/runtime

@cherrymui
Copy link
Member

@laplantePierre are you using Xcode 15? If so, see #61229. This is due to a bug in Apple's new linker. We already worked around it at Go tip, and the next Go 1.21.2 will also have a workaround (#62598). Thanks.

@cherrymui cherrymui added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 21, 2023
@mfreeman451
Copy link

Having the same issue

@sh0umik
Copy link

sh0umik commented Oct 2, 2023

Having the same issue after updating Macos to 13.5.2

@aclements
Copy link
Member

For anyone experiencing this issue, please confirm the version of Xcode and Go you're using. If it's Xcode 15, Go 1.21.2 (expected to come out Thursday) should fix this issue.

@cherrymui
Copy link
Member

Go 1.21.2 is released yesterday and includes workarounds for bugs for the C linker in Xcode 15. Could you update to Go 1.21.2 and see if that fixes the issue? Thanks.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Oct 9, 2023
@gopherbot
Copy link
Contributor

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

7 participants