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

Correct usage of packet.NewPacket() method #681

Closed
AlekseyKanaev opened this issue Dec 27, 2019 · 3 comments
Closed

Correct usage of packet.NewPacket() method #681

AlekseyKanaev opened this issue Dec 27, 2019 · 3 comments

Comments

@AlekseyKanaev
Copy link

Hello!
I have an issue with packet.NewPacket() method, but I don't know whether it is a bug or method misuse. Below is code snippet, which results in segmentation violation error.

package main

import (
	"github.com/intel-go/nff-go/packet"
)

var pkt, err interface{}

func main() {
	pkt, err = packet.NewPacket()

}

Here is the error:

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x44 pc=0x4eba47]

runtime stack:
runtime.throw(0x75519d, 0x2a)
	/usr/local/go/src/runtime/panic.go:774 +0x72
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:378 +0x47c

goroutine 1 [syscall]:
runtime.cgocall(0x4ee8f0, 0xc000058e60, 0xc0000c41f0)
	/usr/local/go/src/runtime/cgocall.go:128 +0x5b fp=0xc000058e30 sp=0xc000058df8 pc=0x439bdb
github.com/intel-go/nff-go/internal/low._Cfunc_allocateMbufs(0x0, 0xc0000b6240, 0x1, 0x0)
	_cgo_gotypes.go:401 +0x4d fp=0xc000058e60 sp=0xc000058e30 pc=0x4e415d
github.com/intel-go/nff-go/internal/low.AllocateMbuf.func1(0x0, 0xc0000b6240, 0xc0000c41e0)
	/home/secret/go/pkg/mod/github.com/intel-go/nff-go@v0.9.2/internal/low/low.go:679 +0x97 fp=0xc000058e98 sp=0xc000058e60 pc=0x4e4547
github.com/intel-go/nff-go/internal/low.AllocateMbuf(0xc0000b6240, 0x0, 0xc000058f50, 0x43c4cf)
	/home/secret/go/pkg/mod/github.com/intel-go/nff-go@v0.9.2/internal/low/low.go:679 +0x39 fp=0xc000058f00 sp=0xc000058e98 pc=0x4e43c9
github.com/intel-go/nff-go/packet.NewPacket(0x0, 0x8e000, 0xc00008c058)
	/home/secret/go/pkg/mod/github.com/intel-go/nff-go@v0.9.2/packet/packet.go:834 +0x50 fp=0xc000058f38 sp=0xc000058f00 pc=0x4e5000
main.main()
	/home/secret/go/src/github.com/MyProject/main.go:10 +0x26 fp=0xc000058f60 sp=0xc000058f38 pc=0x4e52c6
runtime.main()
	/usr/local/go/src/runtime/proc.go:203 +0x21e fp=0xc000058fe0 sp=0xc000058f60 pc=0x4630fe
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1357 +0x1 fp=0xc000058fe8 sp=0xc000058fe0 pc=0x48b7b1

My environment params are:

  • go1.13.4 linux/amd64
  • gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
@gshimansky
Copy link
Contributor

I don't think this function would work correctly before NFF-Go framework is at least initialized, maybe it should be even started to work correctly.

@aregm
Copy link
Owner

aregm commented Jan 3, 2020

@AlekseyKanaev thanks for pointing this out - we should update the documentation to reflect the situation better. Packets are allocated in the memory which is addressable after the NFF-Go is initialized. As a reference example, please look into https://github.com/intel-go/nff-go/blob/master/examples/generate.go It shows how to do the whole flow correctly.

@AlekseyKanaev
Copy link
Author

@AlekseyKanaev thanks for pointing this out - we should update the documentation to reflect the situation better. Packets are allocated in the memory which is addressable after the NFF-Go is initialized. As a reference example, please look into https://github.com/intel-go/nff-go/blob/master/examples/generate.go It shows how to do the whole flow correctly.

Thanks!!! That example helped me to resolve the issue.

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