The structs in use look like this in if_packet.h:

struct tpacket_stats {
     unsigned int tp_packets;
     unsigned int tp_drops;

struct tpacket_stats_v3 {
     unsigned int tp_packets;
     unsigned int tp_drops;
     unsigned int tp_freeze_q_cnt;

The panic seems to happen on the first call to func (h *TPacket) SocketStats()
and since I've managed to see this behavior while doing simple tests, the
tp_packets field should have a small number in it and the rest should be 0.

fredag 18. mars 2016 18.09.31 UTC+1 skrev Ian Lance Taylor følgende:
On Fri, Mar 18, 2016 at 9:24 AM, Lars Kulseng <larsk...@gmail.com
<javascript:>> wrote:
I'm getting the following panic when I use gopacket's SocketStats method wit
hAF_PACKET mode.

panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 18 [running]:
panic(0x854de0, 0xc82212c820)
/usr/local/go/src/runtime/panic.go:464 +0x3e6
0xc82221c0a0, 0xc82212c800, 0x1, 0x1, 0x0)
??:0 +0x4d
0x0, 0x0, 0x0, 0x0, 0x0)



The panic happens here:

Basically, a pointer to a struct "h.socketStatsV3" of type
"C.struct_tpacket_stats_v3" is passed to "C.getsockopt()"
(http://man7.org/linux/man-pages/man2/setsockopt.2.html) and is filled with
socket statistics data.

After reading a little about how the new cgo pointer restrictions are
enforced in Go 1.6, I'm thinking that the passing of
unsafe.Pointer(&h.socketStatsV3) is the culprit, but I'm not sure. I'm also
not sure how to fix this. I am the one that originally contributed this code
to the project, so I feel like I need to help. Compiling with an older Go
version gives no errors.
What does the h.socketStatsV3 field contain when the failing call is made?

The fix may be as simple as clearing that field before the call--I
assume that getsockopt is going to set its contents anyhow.

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 5 | next ›
Discussion Overview
groupgolang-nuts @
postedMar 18, '16 at 4:43p
activeMar 18, '16 at 6:54p

2 users in discussion

Lars Kulseng: 3 posts Ian Lance Taylor: 2 posts



site design / logo © 2022 Grokbase