You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using the plugins feature. created the following two plugins using the command go build -buildmode=plugin
plugin1
package main
import "C"
import "log"
func init() {
log.Printf("testplugin.main.init invoked\n")
}
type innerType struct {
f1 int
f2 string
}
type MyStruct struct {
Name string
Id int
mm map[string]innerType
}
func InitPlugin() {
m := MyStruct{Name: "x", Id: 0}
log.Printf("testplugin.InitPlugin %v", m)
}
plugin2
package main
import "C"
import "log"
func init() {
log.Printf("testplugin1.main.init invoked\n")
}
type innerType struct {
f1 int
f2 string
}
type MyStruct struct {
Name string
Id int
mm map[string]innerType
}
func InitPlugin() {
m := MyStruct{Name: "x", Id: 0}
log.Printf("testplugin1.InitPlugin %v", m)
}
Both plugins have the same code, except the minor difference in print statements.
a main program loads the plugins using the api plugin.Open(pluginpath)
What did you expect to see?
Both plugins loaded succesfully.
What did you see instead?
a stackoverflow error. I have limited the stack using debug.SetMaxStack(100) so that i can see the beginning of the stack.
type MyStruct struct {
Name string
Id int
mm map[string]innerType << using the type in map causes the error
}
If the type is not used in the map, the error is gone, and both plugins can be loaded successfully.
type MyStruct struct {
Name string
Id int
// mm map[string]innerType << commenting this line does not cause the error
}
also, renaming the type innerType to some other name, say, innerType_xyz in one of the plugins also avoids the stackoverflow.
The text was updated successfully, but these errors were encountered:
vimalk78
changed the title
plugin: using same type in map causes stackoverflow
plugin: using same type in map across two plugins causes stackoverflow
Feb 23, 2017
It's walking an infinite list of types caused by the overflow buckets in the map. Each bucket has a has a values field of type innerType, and a pointer to a bucket. Since everything else is identical, it recurses through the bucket pointer back to a bucket, and keeps going.
Any identical recursive type definition in two plugins causes it.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
using the
plugins
feature. created the following two plugins using the commandgo build -buildmode=plugin
plugin1
plugin2
Both plugins have the same code, except the minor difference in print statements.
a main program loads the plugins using the api
plugin.Open(pluginpath)
What did you expect to see?
Both plugins loaded succesfully.
What did you see instead?
a stackoverflow error. I have limited the stack using
debug.SetMaxStack(100)
so that i can see the beginning of the stack.without limiting the stack size, the error is same, except
i narrowed down the issue to this
If the type is not used in the map, the error is gone, and both plugins can be loaded successfully.
also, renaming the type
innerType
to some other name, say,innerType_xyz
in one of the plugins also avoids the stackoverflow.The text was updated successfully, but these errors were encountered: