Closed
Description
I had a crash alexbrainman/odbc#65 after compiling my program with latest version of Go.
I simplified my crash down to this:
# go version
go version devel +e7524d5 Tue Feb 23 03:42:38 2016 +0000 linux/386
# cat -n main.go
1 package main
2
3 import (
4 "unsafe"
5 )
6
7 /*
8 typedef void* VOIDPTR;
9
10 void cfunc(VOIDPTR p) {
11 }
12 */
13 import "C"
14
15 type stru struct {
16 a []byte
17 buf [8]byte
18 }
19
20 func main() {
21 var s stru
22 s.a = s.buf[:]
23 C.cfunc(C.VOIDPTR(unsafe.Pointer(&s.buf[0])))
24 }
# go run main.go
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
panic(0x809e300, 0x1830a040)
/root/go/src/runtime/panic.go:483 +0x331
main.main()
/root/src/t/main.go:23 +0x8c
exit status 2
#
I don't undestand what this program doing wrong that CGO function parmeter checker crashed it. Can someone explain it to me, please? Also, if I remove line 22, the program runs with no problem. Why?
Thank you.
I suspect @ianlancetaylor will be interested.
Alex