Closed jclc closed 6 years ago
Did you use var vkInstance vk.Instance
?
Also, what platform do you have?
Yes, var vkInstance vk.Instance
defined as a package-wide variable. Using Linux desktop. I'm at work right now so I can't post the full thing but there isn't much code before this.
Declaring vkInstance right before the function call instead of as a top-level variable seems to fix that particular error, but now I'm getting a segfault in the C code
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x0]
runtime stack:
runtime.throw(0x4fa724, 0x2a)
/usr/lib/go/src/runtime/panic.go:616 +0x81
runtime.sigpanic()
/usr/lib/go/src/runtime/signal_unix.go:372 +0x28e
goroutine 1 [syscall]:
runtime.cgocall(0x4b9f50, 0xc420069de8, 0x4a6775)
/usr/lib/go/src/runtime/cgocall.go:128 +0x64 fp=0xc420069db8 sp=0xc420069d80 pc=0x412b64
github.com/vulkan-go/vulkan._Cfunc_callVkCreateInstance(0x199aa90, 0x0, 0xc4200a4078, 0x0)
_cgo_gotypes.go:4253 +0x4d fp=0xc420069de8 sp=0xc420069db8 pc=0x4a54ed
github.com/vulkan-go/vulkan.CreateInstance.func1(0x199aa90, 0x0, 0xc4200a4078, 0xc4200a4078)
/home/vhns/projects/go/src/github.com/vulkan-go/vulkan/vulkan.go:24 +0xc4 fp=0xc420069e20 sp=0xc420069de8 pc=0x4a6bd4
github.com/vulkan-go/vulkan.CreateInstance(0xc420069ea8, 0x0, 0xc4200a4078, 0x4f4289)
/home/vhns/projects/go/src/github.com/vulkan-go/vulkan/vulkan.go:24 +0x4d fp=0xc420069e50 sp=0xc420069e20 pc=0x4a69cd
gitlab.com/jclc/game/graphics.Init(0x4f4f61, 0xa, 0xc4200b0020, 0x5074a0)
/home/vhns/projects/go/src/gitlab.com/jclc/game/graphics/vulkan.go:52 +0x254 fp=0xc420069f30 sp=0xc420069e50 pc=0x4a7c94
main.main()
/home/vhns/projects/go/src/gitlab.com/jclc/game/main.go:12 +0x3a fp=0xc420069f88 sp=0xc420069f30 pc=0x4a7f2a
runtime.main()
/usr/lib/go/src/runtime/proc.go:198 +0x212 fp=0xc420069fe0 sp=0xc420069f88 pc=0x439ba2
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc420069fe8 sp=0xc420069fe0 pc=0x460a21
exit status 2
I can build and run the vulkancube demo just fine.
Here's output from GDB. I'm stumped.
(gdb) run
Starting program: /home/vhns/projects/go/src/gitlab.com/jclc/game/game
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff42ae700 (LWP 24598)]
[New Thread 0x7ffff3aad700 (LWP 24599)]
[New Thread 0x7ffff32ac700 (LWP 24600)]
[New Thread 0x7ffff2aab700 (LWP 24601)]
[New Thread 0x7ffff22aa700 (LWP 24602)]
Thread 1 "game" received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) backtrace
#0 0x0000000000000000 in ?? ()
#1 0x00000000004ba04f in _cgo_526486ca5792_Cfunc_callVkCreateInstance (v=0xc420069dd0) at cgo-gcc-prolog:1260
#2 0x000000000045fd20 in runtime.asmcgocall () at /usr/lib/go/src/runtime/asm_amd64.s:688
#3 0x000000c4200a8090 in ?? ()
#4 0x000000c420098450 in ?? ()
#5 0x0000000000000000 in ?? ()
My bad. Didn't realise vulkan-go required a call to Init() from both itself and glfw.
In my defense though, the documentation is pretty much non-existent.
Calling CreateInstance panics with
runtime error: cgo argument has Go pointer to Go pointer
.