iovisor / gobpf

Go bindings for creating BPF programs.
Apache License 2.0
2.14k stars 314 forks source link

TestModuleLoadBCC fails with SIGSEGV #68

Closed dongsupark closed 7 years ago

dongsupark commented 7 years ago

When running go test -v --tags integration on Fedora 26 with kernel 4.11.11, the test TestModuleLoadBCC fails because C.bpf_module_create_c_from_string fails with SIGSEGV. But other normal integration tests work fine with other kernels like 4.10.

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

runtime stack:
runtime.throw(0x505288, 0x2a)
        /usr/local/golang/src/runtime/panic.go:596 +0x95
runtime.sigpanic()
        /usr/local/golang/src/runtime/signal_unix.go:274 +0x2db

goroutine 6 [syscall, locked to thread]:
runtime.cgocall(0x4c4ec0, 0xc420032660, 0x50506e)
        /usr/local/golang/src/runtime/cgocall.go:131 +0xe2 fp=0xc420032620 sp=0xc4200325e0
github.com/iovisor/gobpf/bcc._Cfunc_bpf_module_create_c_from_string(0xa9a940, 0xc400000002, 0xc42000e040, 0x1, 0x0)
        github.com/iovisor/gobpf/bcc/_obj/_cgo_gotypes.go:390 +0x4e fp=0xc420032660 sp=0xc420032620
github.com/iovisor/gobpf/bcc.newModule.func3(0xa9a940, 0x2, 0xc42000e040, 0x1, 0x1)
        /home/dpark/go/src/github.com/iovisor/gobpf/bcc/module.go:85 +0x7a fp=0xc420032698 sp=0xc420032660
github.com/iovisor/gobpf/bcc.newModule(0x5061bc, 0x213, 0x79dea0, 0x0, 0x0, 0x0)
        /home/dpark/go/src/github.com/iovisor/gobpf/bcc/module.go:85 +0x281 fp=0xc420032738 sp=0xc420032698
github.com/iovisor/gobpf/bcc.compile()
        /home/dpark/go/src/github.com/iovisor/gobpf/bcc/module.go:109 +0xc7 fp=0xc4200327e0 sp=0xc420032738
runtime.goexit()
        /usr/local/golang/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc4200327e8 sp=0xc4200327e0
created by github.com/iovisor/gobpf/bcc.bpfInit
        /home/dpark/go/src/github.com/iovisor/gobpf/bcc/module.go:66 +0x15f

goroutine 1 [chan receive]:
github.com/iovisor/gobpf/bcc.NewModule(0x5061bc, 0x213, 0x79dea0, 0x0, 0x0, 0x40e928)
        /home/dpark/go/src/github.com/iovisor/gobpf/bcc/module.go:103 +0x10f
main.main()
        /home/dpark/go/src/github.com/iovisor/gobpf/examples/bcc/ebpf-ex2/ebpf-ex2.go:48 +0x74

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/golang/src/runtime/asm_amd64.s:2197 +0x1

goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
        /usr/local/golang/src/runtime/sigqueue.go:116 +0x104
os/signal.loop()
        /usr/local/golang/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.1
        /usr/local/golang/src/os/signal/signal_unix.go:28 +0x41
schu commented 7 years ago

Maybe the same problem as discussed in iovisor/bcc#1221?

dongsupark commented 7 years ago

@schu Yes, maybe it's the same issue as https://github.com/iovisor/bcc/issues/1221. In my case, Upgrading llvm/clang to the current master(6.0?) didn't fix the issue. BTW I couldn't try llvm v5.0 due to other build issues. So I had to downgrade llvm/clang to 3.9. Now everything works fine. Thanks!

EDIT: Actually I was able to upgrade llvm/clang to 6.0 by rebuilding rpm packages and installing them. That way iovisor/bcc (master) can be built, and bcc examples work fine. The thing is though that iovisor/bcc 0.3.0 cannot be built with llvm/clang 6.0. Without bcc 0.3.0, gobpf won't work at all. So for us, it's the only way to keep llvm/clang 3.9 and bcc 0.3.0.