Skip to content

fix: prevent nil pointer panic in gnutls probe when setup fails#879

Merged
cfc4n merged 4 commits into
masterfrom
copilot/fix-bpf-instruction-error
Dec 2, 2025
Merged

fix: prevent nil pointer panic in gnutls probe when setup fails#879
cfc4n merged 4 commits into
masterfrom
copilot/fix-bpf-instruction-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 29, 2025

Running ecapture gnutls tls -m pcap --pcapfile save.pcapng panics with nil pointer dereference instead of returning a proper error when the BPF manager setup fails.

Root cause: g.bpfManager.InstructionPatchers is accessed when setupManagersPcap() returns an error.

Summary of Changes:

  • Added if err != nil check inside the TlsCaptureModelTypePcap case after setupManagersPcap()
  • Returns error immediately with message prompting the user to check startup parameters
  • Prevents nil pointer dereference when setupManagersPcap() fails

Custom agent used: eCapture-PR-Agent
本 Agent 专门服务于 gojue/ecapture 仓库,用于自动创建 小粒度、可审阅的代码改动 PR

Original prompt

This section details on the original issue you should resolve

<issue_title>panic when bpf instruction not appointed</issue_title>
<issue_description>> [!IMPORTANT]

You can mention the @dosu AI robot, which can quickly answer your questions.

Describe the bug
A clear and concise description of what the bug is.
panic when bpf instruction not appointed instead of notice

To Reproduce
Steps to reproduce the behavior:

  1. ./bin/ecapture gnutls tls -m pcap --pcapfile save.pcapng

Screenshots
If applicable, add screenshots to help explain your problem.

Image

Linux Server/Android (please complete the following information):

  • Device: Linux Server
  • Kernel Info: Linux localhost.localdomain 6.6.0-28.0.0.34.oe2403.x86_64 gojue/ecapture#1 SMP Mon May 27 22:22:46 CST 2024 x86_64 x86_64 x86_64 GNU/Linux
  • eCapture Version: linux_amd64:v1.4.3-20251125-b6b259d:6.6.0-28.0.0.34.oe2403.x86_64

Additional context
Add any other context about the problem here.
</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: eCapture-PR-Agent
本 Agent 专门服务于 gojue/ecapture 仓库,用于自动创建 小粒度、可审阅的代码改动 PR


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Move pcapFilter handling after the error check in MGnutlsProbe.start()
to prevent nil pointer dereference when setupManagersPcap() fails.

This aligns with the pattern used in probe_openssl.go and probe_gotls.go.

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix panic when BPF instruction not appointed fix: prevent nil pointer panic in gnutls probe when setup fails Nov 29, 2025
Copilot AI requested a review from cfc4n November 29, 2025 12:54
@github-actions
Copy link
Copy Markdown

🔧 Debug Build Complete (PR 879, RunID 19784104104)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n cfc4n marked this pull request as ready for review November 29, 2025 15:00
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working labels Nov 29, 2025
Comment thread user/module/probe_gnutls.go
Move error check inside the switch case as requested by @cfc4n.
Only access g.bpfManager.InstructionPatchers when err == nil.

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
Copilot AI requested a review from cfc4n December 2, 2025 13:08
@cfc4n
Copy link
Copy Markdown
Member

cfc4n commented Dec 2, 2025

@copilot 判断方式改为 如果err 不为nil,则抛出错误,停止执行。提示用户调整启动参数。

Changed from `if err == nil` to `if err != nil` pattern that returns
an error immediately with a helpful message to check startup parameters.

Co-authored-by: cfc4n <709947+cfc4n@users.noreply.github.com>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Dec 2, 2025
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 2, 2025

@copilot 判断方式改为 如果err 不为nil,则抛出错误,停止执行。提示用户调整启动参数。

Changed to use if err != nil pattern that returns an error immediately with message: "please check your startup parameters". Commit: 28c1810

Copy link
Copy Markdown
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Dec 2, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 2, 2025

🔧 Debug Build Complete (PR 879, RunID 19859785993)

📦 Download Links:

⏰ Files will be retained for 7 days, please download and test promptly.

@cfc4n cfc4n merged commit 5223547 into master Dec 2, 2025
9 of 10 checks passed
@cfc4n cfc4n deleted the copilot/fix-bpf-instruction-error branch December 2, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic when bpf instruction not appointed

2 participants