Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rajender opened this issue Jan 27, 2016 · 8 comments
Closed

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

rajender opened this issue Jan 27, 2016 · 8 comments

Comments

@rajender
Copy link

pfdump gave following error with go1.6beta2, but working fine with go1.5. Seems like new cgo rules are the reason. See https://tip.golang.org/cmd/cgo/#hdr-Passing_pointers

Starting to read packets
panic: runtime error: cgo argument has Go pointer to Go pointer

goroutine 53 [running]:
github.com/google/gopacket/pfring.(_Ring).ReadPacketDataTo(0xc821280000, 0xc82129a000, 0x10000, 0x10000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/root/ws/src/github.com/google/gopacket/pfring/pfring.go:116 +0x210
github.com/google/gopacket/pfring.(_Ring).ReadPacketData(0xc821280000, 0xc82129a000, 0x10000, 0x10000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/root/ws/src/github.com/google/gopacket/pfring/pfring.go:135 +0xcb
github.com/google/gopacket.(_PacketSource).NextPacket(0xc821270c60, 0x0, 0x0, 0x0, 0x0)
/root/ws/src/github.com/google/gopacket/packet.go:759 +0x76
github.com/google/gopacket.(_PacketSource).packetsToChannel(0xc821270c60)
/root/ws/src/github.com/google/gopacket/packet.go:776 +0x54
created by github.com/google/gopacket.(*PacketSource).Packets
/root/ws/src/github.com/google/gopacket/packet.go:799 +0x7f

@LrsK
Copy link
Contributor

LrsK commented Mar 18, 2016

I am also seeing this with Go 1.6

@gconnell
Copy link
Collaborator

I'm having trouble reproducing this:

gconnell@loftyduck:~/go/src/github.com/google/gopacket/pfring$ uname -a
Linux loftyduck.dls.corp.google.com 3.13.0-77-generic #121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
gconnell@loftyduck:~/go/src/github.com/google/gopacket/pfring$ go version
go version go1.6 linux/amd64
gconnell@loftyduck:~/go/src/github.com/google/gopacket/pfring$ git branch
* master
gconnell@loftyduck:~/go/src/github.com/google/gopacket/pfring$ git pull
Already up-to-date.
gconnell@loftyduck:~/go/src/github.com/google/gopacket/pfring$ go version
go version go1.6 linux/amd64
gconnell@loftyduck:~/go/src/github.com/google/gopacket/pfring$ go build && echo SUCCESS
SUCCESS

@LrsK
Copy link
Contributor

LrsK commented Mar 18, 2016

It happens at runtime for me when using the afpacket mode and fetching the stats using tpacket.SocketStats(). It fails here for me: https://github.com/google/gopacket/blob/master/afpacket/afpacket.go#L293 but I'm able to capture packets without issues.

@LrsK
Copy link
Contributor

LrsK commented Mar 18, 2016

I've been discussing this with the golang Google group, and it seems like the pointer checker is a bit overzealous in this case.

Their suggestion was to go from:

_, err := C.getsockopt(h.fd, C.SOL_PACKET, C.PACKET_STATISTICS, unsafe.Pointer(&h.socketStatsV3), &slt)

to something like:

var ssv3 SocketStatsV3
C.getsockopt(..., &ssv3, ...)
h.socketStatsV3 = ssv3

I will try this and report back.

gconnell added a commit to gconnell/gopacket that referenced this issue Mar 18, 2016
This should fix the Go runtime panic caused by Go-pointer-to-pointer
introduced in Go 1.6.
@gconnell
Copy link
Collaborator

Could you try this pull request to see if it fixes your issue?

#180

@LrsK
Copy link
Contributor

LrsK commented Mar 18, 2016

#180 Did fix the pfring code, I have confirmed that now. As you can see I also added a fix for the socket stats.

@LrsK
Copy link
Contributor

LrsK commented Mar 19, 2016

#182 added for your consideration. It simplifies the code in PR #181

@gconnell
Copy link
Collaborator

182 merged, closing as I think this is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants