'Panic Related to Garbage Collector When Running Go Program
I installed a Go program from GitHub and when I run it, I get the error,
panic: Something in this program imports go4.org/unsafe/assume-no-moving-gc to declare that it assumes a non-moving garbage collector, but your version of go4.org/unsafe/assume-no-moving-gc hasn't been updated to assert that it's safe against the go1.18 runtime. If you want to risk it, run with environment variable ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH=go1.18 set. Notably, if go1.18 adds a moving garbage collector, this program is unsafe to use.
It appears that there isn't much information related to this out there. I have zero experience coding in Go.
Any help is much appreciated. I'll be happy to provide any extra information you might need.
PS: The program I installed is metabignor and it was installed with go install github.com/j3ssie/metabigor@latest
.
Solution 1:[1]
the panic error is triggered by the library you imported.
https://github.com/go4org/unsafe-assume-no-moving-gc/blob/main/untested.go
func init() {
dots := strings.SplitN(runtime.Version(), ".", 3)
v := runtime.Version()
if len(dots) >= 2 {
v = dots[0] + "." + dots[1]
}
if os.Getenv(env) == v {
return
}
panic("Something in this program imports go4.org/unsafe/assume-no-moving-gc to declare that it assumes a non-moving garbage collector, but your version of go4.org/unsafe/assume-no-moving-gc hasn't been updated to assert that it's safe against the " + v + " runtime. If you want to risk it, run with environment variable " + env + "=" + v + " set. Notably, if " + v + " adds a moving garbage collector, this program is unsafe to use.")
}
as what the error said, you need to set this env var
ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH=go1.18
or, upgrade the go runtime to go1.19
Solution 2:[2]
you can also upgrade assume-no-moving-gc
by using go get -u go4.org/unsafe/assume-no-moving-gc
to solve this problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | GUO Lucky |