Skip to content

tracing: run USDT tests without BPF privileges - #36627

Open
willcl-ark wants to merge 2 commits into
bitcoin:masterfrom
willcl-ark:tracing-no-sudo
Open

willcl-ark wants to merge 2 commits into
bitcoin:masterfrom
willcl-ark:tracing-no-sudo

Conversation

@willcl-ark

@willcl-ark willcl-ark commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

The USDT functional tests currently use BCC to attach eBPF programs to Bitcoin Core’s tracepoints. This requires BCC, matching kernel headers, and elevated BPF permissions, making the tests awkward to run locally and
requiring a privileged container in CI.

Replace the BCC consumers with GDB. Each tested node runs as a debugger child, allowing the tests to enable the real USDT probes and inspect their arguments when execution reaches the probe location. This continues to test
the parts of the USDT interface provided by Bitcoin Core:

  • the probe metadata is present and understood;
  • the probes can be enabled and are reached in the expected scenarios; and
  • their arguments have the expected values, sizes, and lifetimes.

All five tests can run with GDB and binutils, without BCC or matching kernel headers. The ASan CI job no longer needs a privileged container and uses SYS_PTRACE instead. This also removes the embedded BPF programs from
the tests, reducing their size and maintenance burden. Overall, the change removes roughly 660 lines of test and CI code.

Tradeoffs

  • These tests no longer exercise the consumer-side eBPF path, including BCC compilation, kernel BPF verification and loading, uprobe attachment, BPF-side argument decoding, and perf-buffer delivery. Problems confined to
    those components would no longer be detected here.
  • LeakSanitizer is disabled for nodes run under GDB because it cannot operate under ptrace. Other sanitizer checks remain enabled.

The remaining coverage is focused on Bitcoin Core’s side of the USDT interface. Testing the general BCC, eBPF, and kernel uprobe is left to those consumers and the kernel.

@DrahtBot

DrahtBot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK fanquake, 0xB10C, w0xlt

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)
  • #36872 (ci: Share qa-assets across GitHub Actions jobs by jaromil)
  • #36540 (mempool: remove time-based transaction expiry by ismaelsadeeq)
  • #36257 (qa: assert_equal -> assert_true/assert_false by hodlinator)
  • #34405 (wallet: skip APS when no partial spend exists by 8144225309)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible places where comparison-specific test macros should replace generic comparisons:

  • test/functional/interface_usdt_utxocache.py: assert event.memory > 0 → Prefer assert_greater_than(event.memory, 0).
  • test/functional/interface_usdt_utxocache.py: assert event.duration > 0 → Prefer assert_greater_than(event.duration, 0).

2026-11-05 15:31:11

@fanquake

Copy link
Copy Markdown
Member

Concept ACK

@fanquake

Copy link
Copy Markdown
Member

cc @0xB10C

@willcl-ark

Copy link
Copy Markdown
Member Author

I beefed up the tradeoffs section here as I think it may have been undersold in its previous form.

@0xB10C

0xB10C commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Concept ACK.

Nice, I didn't know this was possible. I think it's a nice simplification and agree that we should test our interface, and not bcc which might or might not break from time to time. I plan to review this in more detail.

Does this also make the tests work aarch64 ref #35142 (comment)?

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does this fit into the large picture in #35142 ?

Comment thread .github/workflows/ci.yml Resolved
Comment thread ci/test/00_setup_env_native_asan.sh Resolved
@willcl-ark

Copy link
Copy Markdown
Member Author

How does this fit into the large picture in #35142 ?

Sorry meant to reply here sooner but got distracted.

Of course the value to us of this patchset depends somewhat on whether we opt to keep tracing in-repo (vs as an external patchset). If we want to drop it, then this change is moot.

With b10c and the FIBRE team both using tracing actively it seems both would (naturally) prefer to keep it in-tree if possible. This seems fine to me, and I see this patchset as reducing the maintenance burden (to us) of keeping it here in its current form as it:

  • removes BCC, root, and host-kernel requirements from functional testing
  • preserves the USDT probes and existing production eBPF consumers.

Launch traced nodes as GDB children so the existing probe scenarios can
run without BCC, BPF privileges, or matching host kernel headers.

- Copy probe arguments while stopped and drain complete records in the
  test process, including events emitted during node shutdown and
  restart.
- Follow the bitcoin launcher through exec before registering probes.
- Handle a GDB parser failure for GCC byte-register operands in usdt.py.
- Disable LeakSanitizer only for traced children because it cannot
  operate under ptrace; keep other sanitizer checks remain enabled.
The USDT tests now launch nodes under GDB, so the ASan job no longer needs
BCC, matching host kernel headers, or a privileged container. Install GDB
and binutils and retain SYS_PTRACE for debugger and sanitizer operation.
Remove the host-kernel package refresh and BCC workflow toggle along with
the dependencies they supported.
@willcl-ark

Copy link
Copy Markdown
Member Author

Pushed to take one ralph finding.

The other suggestion does highlight a possible limitation, but I don't think it affects anything. The current binary has one site per probe name, so the fallback selects the correct layout.

@w0xlt

w0xlt commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

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

Successfully merging this pull request may close these issues.

6 participants