Closed napsy closed 8 years ago
What is the code you tested with?
It goes something like this:
import (
msgpack "gopkg.in/vmihailenco/msgpack.v2"
"github.com/pebbe/zmq4"
)
...
// marshal using msgpack
data, err := msgpack.Marshal(map[string]string{"hello":"world"})
parts := [][]byte{[]byte("aRoute"), data}
publisher.SendMessage(parts)
I don't get this panic in go1.5.2 I also don't get this panic in Go 1.6 when I change the code to this:
data := []byte("\x81\xa5hello\xa5world")
parts := [][]byte{[]byte("aRoute"), data}
publisher.SendMessage(parts)
Perhaps a bug in Go 1.6?
Full working example:
package main
import (
zmq "github.com/pebbe/zmq4"
msgpack "gopkg.in/vmihailenco/msgpack.v2"
"fmt"
"log"
)
func main() {
pub, err := zmq.NewSocket(zmq.PUB)
if err != nil {
log.Fatal(err)
}
err = pub.Bind("tcp://127.0.0.1:9997")
if err != nil {
log.Fatal(err)
}
data, err := msgpack.Marshal(map[string]string{"hello": "world"})
if err != nil {
log.Fatal(err)
}
// uncommenting the next line makes the panic disappear
//data = []byte("\x81\xa5hello\xa5world")
parts := [][]byte{[]byte("aRoute"), data}
n, err := pub.SendMessage(parts)
if err != nil {
log.Fatal(err)
}
fmt.Println(n)
}
I tried your example again with 1.6 beta1 (linux/amd64) and I get the same panic:
panic: runtime error: cgo argument has Go pointer to Go pointer
goroutine 1 [running]:
github.com/pebbe/zmq4._cgoCheckPointer0(0x505400, 0xc820012104, 0x0, 0x0, 0x0, 0x2351170)
??:0 +0x4d
github.com/pebbe/zmq4.(*Socket).SendBytes(0xc8200148a0, 0xc820012104, 0xd, 0x40, 0x0, 0x6, 0x0, 0x0)
/home/napsy/git/koala2/src/github.com/pebbe/zmq4/zmq4.go:769 +0x16b
github.com/pebbe/zmq4.(*Socket).sendMessage(0xc8200148a0, 0x0, 0xc82004be70, 0x1, 0x1, 0x6, 0x0, 0x0)
/home/napsy/git/koala2/src/github.com/pebbe/zmq4/utils.go:66 +0x4b4
github.com/pebbe/zmq4.(*Socket).SendMessage(0xc8200148a0, 0xc82004be70, 0x1, 0x1, 0xc82000e4c0, 0x0, 0x0)
/home/napsy/git/koala2/src/github.com/pebbe/zmq4/utils.go:18 +0x56
main.main()
/home/napsy/git/koala2/test.go:29 +0x622
It seems that this is indeed a go1.6 bug
@napsy I tested with Go tip, and it is working fine. Can you test your code too?
@pebbe yes on go tip it works, closing.
I tested the latest zmq4 code using Go 1.6 beta1 and this is what I get
I tried to modify
socket.SendBytes
by getting the[]byte
header and the send only the bytes but it resulted in the same error:The
[]byte
slice in question is nothing but a serializedmap[string]string
.