Closed GoogleCodeExporter closed 9 years ago
Looking at the panic, this may be a bug in Go itself...have you tried compiling
any other programs that require cgo with Go 1.3?
Original comment by rthornto...@gmail.com
on 21 Jun 2014 at 2:02
It looks like cgo works in simple cases. Test case borrows from cgo's
introductory documentation:
$ cat rand/rand.go
package rand
/*
#include <stdlib.h>
*/
import "C"
func Random() int {
return int(C.random())
}
func Seed(i int) {
C.srandom(C.uint(i))
}
$ go install rand
$ cat rand_print.go
package main
import (
"fmt"
"rand"
)
func main() {
fmt.Printf("rand %d\n", rand.Random())
}
$ go run rand_print.go
rand 1804289383
Original comment by mmo...@gmail.com
on 21 Jun 2014 at 2:54
I admit, this is a strange error. I don't really have a place to start on
diagnosing this issue as none of the above errors relate directly to the
library and I don't have access to a Mac for testing. Posting on mailing list
to see what I can turn up.
Original comment by rthornto...@gmail.com
on 24 Jun 2014 at 1:03
Could you try to compile a simple cgo example with a declared Go type for a C
type? Specifically, with a C struct type.
Original comment by rthornto...@gmail.com
on 24 Jun 2014 at 1:10
I get the same behavior on a completely different project. Perhaps this gives
some clue?
Same version of OS X 10.9.3
mp:~ gary$ go version
go version go1.3 darwin/amd64
mp:~ gary$ go get -u github.com/andlabs/ui
# github.com/andlabs/ui
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x15672]
goroutine 16 [running]:
runtime.panic(0x1dae60, 0x31b9e4)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
main.(*typeConv).Type(0x20837e2c0, 0x22083853f0, 0x208483f50, 0x29f8,
0x2084a2e01)
/usr/local/go/src/cmd/cgo/gcc.go:1288 +0x1632
main.(*typeConv).Type(0x20837e2c0, 0x22083853b8, 0x208483ef0, 0x29f8, 0x1)
/usr/local/go/src/cmd/cgo/gcc.go:1189 +0x3dd6
main.(*typeConv).Type(0x20837e2c0, 0x2208385558, 0x20847cc40, 0x29f8, 0x0)
/usr/local/go/src/cmd/cgo/gcc.go:1075 +0x387f
main.(*typeConv).Struct(0x20837e2c0, 0x208373980, 0x29f8, 0x6, 0x0, 0x0, 0x8)
/usr/local/go/src/cmd/cgo/gcc.go:1551 +0x70b
main.(*typeConv).Type(0x20837e2c0, 0x2208385428, 0x208373980, 0x29f8, 0x1)
/usr/local/go/src/cmd/cgo/gcc.go:1234 +0x3038
main.(*typeConv).Type(0x20837e2c0, 0x22083853b8, 0x208483da0, 0x29f8, 0x0)
/usr/local/go/src/cmd/cgo/gcc.go:1189 +0x3dd6
main.(*typeConv).Struct(0x20837e2c0, 0x208372c60, 0x29f8, 0x6, 0x0, 0x0, 0x8)
/usr/local/go/src/cmd/cgo/gcc.go:1551 +0x70b
main.(*typeConv).Type(0x20837e2c0, 0x2208385428, 0x208372c60, 0x29f8, 0xb2e01)
/usr/local/go/src/cmd/cgo/gcc.go:1234 +0x3038
main.(*typeConv).Type(0x20837e2c0, 0x22083853b8, 0x208482b70, 0x29f8,
0x2084e13f0)
/usr/local/go/src/cmd/cgo/gcc.go:1189 +0x3dd6
main.(*typeConv).Type(0x20837e2c0, 0x22083853f0, 0x208482a80, 0x29f8, 0x26d420)
/usr/local/go/src/cmd/cgo/gcc.go:1269 +0x1301
main.(*typeConv).Struct(0x20837e2c0, 0x208372420, 0x29f8, 0x6, 0x0, 0x0, 0x0)
/usr/local/go/src/cmd/cgo/gcc.go:1551 +0x70b
main.(*typeConv).Type(0x20837e2c0, 0x2208385428, 0x208372420, 0x29f8,
0x2084da001)
/usr/local/go/src/cmd/cgo/gcc.go:1234 +0x3038
main.(*typeConv).Type(0x20837e2c0, 0x22083853b8, 0x208482900, 0x29f8,
0x2084e13e0)
/usr/local/go/src/cmd/cgo/gcc.go:1189 +0x3dd6
main.(*typeConv).Type(0x20837e2c0, 0x22083853f0, 0x208482840, 0x29f8, 0x1)
/usr/local/go/src/cmd/cgo/gcc.go:1269 +0x1301
main.(*Package).loadDWARF(0x20836e8f0, 0x2083ca080, 0x20837d800, 0x19, 0x20)
/usr/local/go/src/cmd/cgo/gcc.go:541 +0xfb4
main.(*Package).Translate(0x20836e8f0, 0x2083ca080)
/usr/local/go/src/cmd/cgo/gcc.go:182 +0x150
main.main()
/usr/local/go/src/cmd/cgo/main.go:259 +0xef1
goroutine 19 [finalizer wait]:
runtime.park(0x4fed0, 0x31feb8, 0x31f269)
/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x31feb8, 0x31f269)
/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
Original comment by sca...@gmail.com
on 24 Jun 2014 at 3:02
It was suggested on the mailling list that this could possibly do to libraries
not being updated to Go 1.3. You can try go install -a or deleting
$GOPATH/{bin,pkg} to clear out old libraries.
Thread at https://mail.google.com/mail/u/0/#inbox/146cb6e98e8e056d
Original comment by rthornto...@gmail.com
on 24 Jun 2014 at 3:27
$ cd ~/go
$ rm -rf pkg bin
$ go install code.google.com/p/goncurses
# code.google.com/p/goncurses
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x15672]
$ sudo rm -rf /usr/local/go/pkg /usr/local/go/bin
. . . reinstall Go here . . .
$ go install code.google.com/p/goncurses
# code.google.com/p/goncurses
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x15672]
$ sudo bash
# export GOPATH=~/go
# go install -a code.google.com/p/goncurses
# code.google.com/p/goncurses
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x15672]
Original comment by mmo...@gmail.com
on 24 Jun 2014 at 1:28
Replying to #4 (above) I got enough time to finally finish an example of a
declared Go type using a C structure and calling native functions.
http://www.mischiefblog.com/2014/06/26/example-cgo-golang-app-that-calls-a-nativ
e-library-with-a-c-structure/
Original comment by mmo...@gmail.com
on 26 Jun 2014 at 6:54
This may be related to Issue 19:
https://code.google.com/p/goncurses/issues/detail?id=19&can=1
Try updating to Go 1.3.1 and see if it fixes the problem.
Original comment by rthornto...@gmail.com
on 20 Aug 2014 at 6:59
Works under 1.3.1
$ go version
go version go1.3.1 darwin/amd64
Needs export CC=clang.
Original comment by mmo...@gmail.com
on 17 Sep 2014 at 5:05
Original comment by rthornto...@gmail.com
on 17 Sep 2014 at 5:13
Original issue reported on code.google.com by
mmo...@gmail.com
on 21 Jun 2014 at 1:40