Closed pztrn closed 7 years ago
Tested on go devel - with go run -race
message is still here.
go-gtk doesn't care of race.
Ok, so I'm closing then, thanks for clarification.
Sorry, I'm reopening, with new additions to original bugreport: now it happens on Windows only, even with go devel:
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running, locked to thread]:
panic(0x69fa60, 0xc0422a0ad0)
C:/msys64/home/pztrn/go-git/src/runtime/panic.go:531 +0x1dd
github.com/mattn/go-gtk/gtk.(*TreeModel).GetValue.func1(0xf2eb30, 0xc042441700, 0x2, 0xc042441740)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:7832 +0xeb
github.com/mattn/go-gtk/gtk.(*TreeModel).GetValue(0xc042004028, 0xc042441700, 0x2, 0xc042441740)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:7841 +0x64
github.com/pztrn/urtrator/ui.(*MainWindow).sortServersByName(0xc0420846e0, 0xc042004028, 0xc042441700, 0xc042441720, 0xc042441720)
C:/msys64/home/pztrn/GOPATH/src/github.com/pztrn/urtrator/ui/mainwindow_servers_sorting.go:19 +0x3ff
github.com/pztrn/urtrator/ui.(*MainWindow).(github.com/pztrn/urtrator/ui.sortServersByName)-fm(0xc042004028, 0xc042441700, 0xc042441720, 0xc0424e8048)
C:/msys64/home/pztrn/GOPATH/src/github.com/pztrn/urtrator/ui/mainwindow_init.go:448 +0x4f
github.com/mattn/go-gtk/gtk._go_call_sort_func(0x47205f0)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:9023 +0x1b8
github.com/mattn/go-gtk/gtk._cgoexpwrap_7e57c1b41650__go_call_sort_func(0x47205f0)
github.com/mattn/go-gtk/gtk/_obj/_cgo_gotypes.go:21625 +0x32
github.com/mattn/go-gtk/gtk._Cfunc__gtk_list_store_set_ptr(0xf2eb30, 0xc0424416e0, 0x0, 0xf20ea0)
github.com/mattn/go-gtk/gtk/_obj/_cgo_gotypes.go:2872 +0x4c
github.com/mattn/go-gtk/gtk.(*ListStore).SetValue.func4(0xf2eb30, 0xc0424416e0, 0x0, 0xf20ea0)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:9324 +0x14e
github.com/mattn/go-gtk/gtk.(*ListStore).SetValue(0xc04200f790, 0xc0424416e0, 0x0, 0x674f00, 0xf20ea0)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:9326 +0x1d9
github.com/pztrn/urtrator/ui.(*MainWindow).loadAllServers(0xc0420846e0, 0xc04217cd50)
C:/msys64/home/pztrn/GOPATH/src/github.com/pztrn/urtrator/ui/mainwindow.go:358 +0xb52
github.com/pztrn/urtrator/ui.(*MainWindow).(github.com/pztrn/urtrator/ui.loadAllServers)-fm(0xc04217cd50)
C:/msys64/home/pztrn/GOPATH/src/github.com/pztrn/urtrator/ui/mainwindow_init.go:174 +0x3b
github.com/pztrn/urtrator/eventer.(*Eventer).reallyLaunchEvent(0xc042004080, 0x6fafa7, 0xe, 0xc04217cd50)
C:/msys64/home/pztrn/GOPATH/src/github.com/pztrn/urtrator/eventer/eventer_object.go:64 +0x19e
github.com/pztrn/urtrator/eventer.(*Eventer).LaunchEvent.func1(0x0)
C:/msys64/home/pztrn/GOPATH/src/github.com/pztrn/urtrator/eventer/eventer_object.go:54 +0x4c
reflect.Value.call(0x683260, 0xc04217cd80, 0x13, 0x6f55be, 0x4, 0xa3b2b0, 0x0, 0x0, 0xc04217cdb0, 0x675040, ...)
C:/msys64/home/pztrn/go-git/src/reflect/value.go:434 +0x926
reflect.Value.Call(0x683260, 0xc04217cd80, 0x13, 0xa3b2b0, 0x0, 0x0, 0x3, 0xc04201e000, 0xc04200c300)
C:/msys64/home/pztrn/go-git/src/reflect/value.go:302 +0xab
github.com/mattn/go-gtk/glib._go_glib_sourcefunc(0x47e2580)
github.com/mattn/go-gtk/glib/_obj/glib.cgo1.go:1690 +0x134
github.com/mattn/go-gtk/glib._cgoexpwrap_08b8c9044f35__go_glib_sourcefunc(0x47e2580)
github.com/mattn/go-gtk/glib/_obj/_cgo_gotypes.go:1849 +0x32
github.com/mattn/go-gtk/gtk._Cfunc_gtk_main()
github.com/mattn/go-gtk/gtk/_obj/_cgo_gotypes.go:10359 +0x48
github.com/mattn/go-gtk/gtk.Main()
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:1041 +0x1b
github.com/pztrn/urtrator/ui.(*MainWindow).Initialize(0xc0420846e0)
C:/msys64/home/pztrn/GOPATH/src/github.com/pztrn/urtrator/ui/mainwindow_init.go:168 +0xe82
yet macOS and Linux builds fine with go devel.
This can be repro with latest git for https://github.com/pztrn/urtrator
Could you please make minimal example to reproduce?
Of course.
package main
import (
"strconv"
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
var (
mainwindow *gtk.Window
vbox *gtk.VBox
treeview *gtk.TreeView
treeview_store *gtk.ListStore
treeview_store_sortable *gtk.TreeSortable
)
func close() {
gtk.MainQuit()
}
func sortFunction(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter, col int) int {
var item1_raw glib.GValue
var item2_raw glib.GValue
model.GetValue(a, col, &item1_raw)
model.GetValue(b, col, &item2_raw)
item1, _ := strconv.Atoi(item1_raw.GetString())
item2, _ := strconv.Atoi(item2_raw.GetString())
if item1 < item2 {
return 1
} else {
return -1
}
return 0
}
func sortFunc1(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int {
return sortFunction(model, a, b, 0)
}
func sortFunc2(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int {
return sortFunction(model, a, b, 1)
}
func sortFunc3(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int {
return sortFunction(model, a, b, 2)
}
func main() {
gtk.Init(nil)
mainwindow := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
mainwindow.SetTitle("TreeView sorting test")
mainwindow.Connect("destroy", close)
mainwindow.SetDefaultSize(500, 500)
vbox := gtk.NewVBox(false, 0)
treeview := gtk.NewTreeView()
treeview_store := gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_STRING)
treeview_store_sortable := gtk.NewTreeSortable(treeview_store)
treeview.SetModel(treeview_store)
col1 := gtk.NewTreeViewColumnWithAttributes("1", gtk.NewCellRendererText(), "markup", 0)
col1.SetSortColumnId(0)
treeview.AppendColumn(col1)
col2 := gtk.NewTreeViewColumnWithAttributes("2", gtk.NewCellRendererText(), "markup", 1)
col2.SetSortColumnId(1)
treeview.AppendColumn(col2)
col3 := gtk.NewTreeViewColumnWithAttributes("3", gtk.NewCellRendererText(), "markup", 2)
col3.SetSortColumnId(2)
treeview.AppendColumn(col3)
treeview_store_sortable.SetSortColumnId(0, gtk.SORT_ASCENDING)
treeview_store_sortable.SetSortFunc(0, sortFunc1)
treeview_store_sortable.SetSortFunc(1, sortFunc2)
treeview_store_sortable.SetSortFunc(2, sortFunc3)
swin1 := gtk.NewScrolledWindow(nil, nil)
swin1.Add(treeview)
vbox.PackStart(swin1, true, true, 0)
mainwindow.Add(vbox)
mainwindow.ShowAll()
for i := 0; i < 10000; i++ {
iter := new(gtk.TreeIter)
treeview_store.Append(iter)
treeview_store.SetValue(iter, 0, strconv.Itoa(i))
treeview_store.SetValue(iter, 1, strconv.Itoa(i + 100 / 20))
treeview_store.SetValue(iter, 2, strconv.Itoa(i + 200 / 10))
}
gtk.Main()
}
Work fine on Linux and macOS, on windows it's crashing with following traceback:
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
panic(0x5377a0, 0xc04200e3d0)
C:/msys64/home/pztrn/go-git/src/runtime/panic.go:531 +0x1dd
github.com/mattn/go-gtk/gtk.(*TreeModel).GetValue.func1(0x86ed30, 0xc042002980, 0x0, 0xc0420029c0)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:7832 +0xeb
github.com/mattn/go-gtk/gtk.(*TreeModel).GetValue(0xc042004080, 0xc042002980, 0x0, 0xc0420029c0)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:7841 +0x64
main.sortFunction(0xc042004080, 0xc042002960, 0xc042002980, 0x0, 0xc042002980)
C:/msys64/home/pztrn/1.go:28 +0xb4
main.sortFunc1(0xc042004080, 0xc042002960, 0xc042002980, 0xc042052048)
C:/msys64/home/pztrn/1.go:43 +0x4f
github.com/mattn/go-gtk/gtk._go_call_sort_func(0x38bb700)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:9023 +0x1b8
github.com/mattn/go-gtk/gtk._cgoexpwrap_7e57c1b41650__go_call_sort_func(0x38bb700)
github.com/mattn/go-gtk/gtk/_obj/_cgo_gotypes.go:21625 +0x32
github.com/mattn/go-gtk/gtk._Cfunc_gtk_list_store_set_value(0x86ed30, 0xc042002940, 0xc000000000, 0x38fe710)
github.com/mattn/go-gtk/gtk/_obj/_cgo_gotypes.go:10328 +0x4c
github.com/mattn/go-gtk/gtk.(*ListStore).SetValue.func1(0x86ed30, 0xc042002940, 0x0, 0x38fe710)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:9291 +0x115
github.com/mattn/go-gtk/gtk.(*ListStore).SetValue(0xc04200e250, 0xc042002940, 0x0, 0x52a720, 0xc04200e360)
github.com/mattn/go-gtk/gtk/_obj/gtk.cgo1.go:9299 +0x227
main.main()
C:/msys64/home/pztrn/1.go:98 +0x5ca
exit status 2
Done some testing with my example - all works if I comment this line:
treeview_store_sortable.SetSortColumnId(0, gtk.SORT_ASCENDING)
Yep, confirming, it works :) Thanks!
Just ran
go run -race
and:Is that normal?