Skip to content

Commit

Permalink
Fix a panic when stop pwru early
Browse files Browse the repository at this point in the history
Fix this panic:

$ sudo ./pwru --output-tuple 'dst host 1.0.0.1 and port 8080'
2024/11/12 13:58:41 Attaching kprobes (via kprobe)...
102 / 1255 [---------->_________________________________________________________________________________________________________________________] 8.13% 96 p/s
231 / 1255 [----------------------->__________________________________________________________________________________________________________] 18.41% 120 p/s
2024/11/12 13:58:43 Listening for events..
SKB                CPU PROCESS          NETNS      MARK/x        IFACE       PROTO  MTU   LEN   TUPLE FUNC
2024/11/12 13:58:43 Received signal, exiting program..
2024/11/12 13:58:43 Detaching kprobes...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6675d8]

goroutine 1 [running]:
github.com/cilium/pwru/internal/pwru.(*kprober).DetachKprobes(0x0)
	/root/Projects/leonhwang/pwru/internal/pwru/kprobe.go:130 +0xb8
main.main()
	/root/Projects/leonhwang/pwru/main.go:322 +0x2013

Signed-off-by: Leon Hwang <[email protected]>
  • Loading branch information
Asphaltt authored and brb committed Nov 19, 2024
1 parent fb15389 commit dbaa406
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/pwru/kprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func NewKprober(ctx context.Context, funcs Funcs, coll *ebpf.Collection, a2n Add
bar.Finish()
select {
case <-ctx.Done():
return nil
return &k
default:
}
log.Printf("Attached (ignored %d)\n", ignored)
Expand Down

0 comments on commit dbaa406

Please sign in to comment.