go-qml / qml

QML support for the Go language
Other
1.96k stars 187 forks source link

Crash when running example #139

Open yuntan opened 9 years ago

yuntan commented 9 years ago

Go 1.4, Qt 5.4.0, Arch Linux 64bit

I installed qml by go get gopkg.in/qml.v1.

When I run example code (ex. control/gallery) by go run gallery.go, I got message and application crashed.

fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x0 pc=0x7f541af10b2a]

runtime stack:
runtime.gothrow(0x5c4630, 0x2a)
        /usr/local/go/src/runtime/panic.go:503 +0x8e
runtime.sigpanic()
        /usr/local/go/src/runtime/sigpanic_unix.go:14 +0x5e

goroutine 1 [syscall, locked to thread]:
runtime.cgocall_errno(0x43edb0, 0xc208031e80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:130 +0xf5 fp=0xc208031e60 sp=0xc208031e38
gopkg.in/qml%2ev1._Cfunc_newGuiApplication()
        /home/yuntan/Workspace/go/src/gopkg.in/qml.v1/:251 +0x45 fp=0xc208031e80 sp=0xc208031e60
gopkg.in/qml%2ev1.Run(0x5d1e78, 0x0, 0x0)
        /home/yuntan/Workspace/go/src/gopkg.in/qml.v1/bridge.go:55 +0x12a fp=0xc208031ee0 sp=0xc208031e80
main.main()
        /home/yuntan/Workspace/go/src/gopkg.in/qml.v1/examples/controls/gallery/gallery.go:10 +0x32 fp=0xc208031f98 sp=0xc208031ee0
runtime.main()
        /usr/local/go/src/runtime/proc.go:63 +0xf3 fp=0xc208031fe0 sp=0xc208031f98
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2232 +0x1 fp=0xc208031fe8 sp=0xc208031fe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2232 +0x1
exit status 2

I removed static library by rm -rf $GOPATH/pkg/linux_amd64/gopkg.in/qml.v1* and re-run but the problem still happen.

yuntan commented 9 years ago

I debugged the program by liteide debugger and finally got the cause of this problem. SIGSEGV is occued at https://github.com/go-qml/qml/blob/1116cb9cd8dee23f8d444ded354eb53122739f99/cpp/capi.cpp#L51 .

I tried to use Go's os.Args as argc, argv and it resolved this problem. Please see https://github.com/yuntan/qml/commit/e4ec67dadf1fcd1e8fcfe95ff62835151c42e7e6 .

luna-duclos commented 9 years ago

I can confirm this fix also properly worked for me. Could this be merged into master ?

niemeyer commented 9 years ago

Thanks for these details. Taking over Go's argv is not the proper fix as it would create problems when you do want to use arguments yourself, but I will have a look at it and see what the proper fix is.

John-Gee commented 9 years ago

Hi there,

I just ran in the same issue after not using go-qml in a while and yuntan's fix worked for me as well. Hoping for something in the official repo as that would be easier to distribute :)