tracing: run USDT tests without BPF privileges #36627

Open
willcl-ark wants to merge 2 commits from tracing-no-sudo into master AGit
willcl-ark commented 2026-10-23 16:08:24 +00:00 (Migrated from github.com)

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.

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 commented 2026-10-23 16:08:33 +00:00 (Migrated from github.com)

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

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36627 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36627.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36627#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [fanquake](https://github.com/bitcoin/bitcoin/pull/36627#issuecomment-6369364243), [0xB10C](https://github.com/bitcoin/bitcoin/pull/36627#issuecomment-6373632789), [w0xlt](https://github.com/bitcoin/bitcoin/pull/36627#issuecomment-6806783295) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) * [#36872](https://github.com/bitcoin/bitcoin/pull/36872) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36872.svg"></sub> (ci: Share qa-assets across GitHub Actions jobs by jaromil) * [#36540](https://github.com/bitcoin/bitcoin/pull/36540) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36540.svg"></sub> (mempool: remove time-based transaction expiry by ismaelsadeeq) * [#36257](https://github.com/bitcoin/bitcoin/pull/36257) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36257.svg"></sub> (qa: assert_equal -> assert_true/assert_false by hodlinator) * [#34405](https://github.com/bitcoin/bitcoin/pull/34405) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34405.svg"></sub> (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. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### 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)`. <sup>2026-11-05 15:31:11</sup>
fanquake commented 2026-10-23 16:13:14 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
fanquake commented 2026-10-23 16:13:26 +00:00 (Migrated from github.com)

cc @0xB10C

cc @0xB10C
First-time contributor

🔵 Suggestion · GDB capture does not assert integer argument types

Value-preserving width changes can pass the USDT tests because capture converts arguments to Python integers without checking the documented widths or signedness.

Location: test/functional/test_framework/usdt.py:103 (head).

🔵 Suggestion · Runtime probe enabling is no longer exercised

Enabling every probe before daemon initialization leaves the USDT tests unable to detect regressions specific to consumers attaching to an already-running node.

Location: test/functional/test_framework/usdt.py:38 (head).

🔵 Suggestion · readelf fallback conflates multiple locations of a probe

If a probe has multiple compiled locations with different operands, the byte-register fallback can record incorrect arguments by using one location's layout for every hit.

Location: test/functional/test_framework/usdt.py:109 (head).

🔵 Suggestion · USDT prerequisite check misses denied child tracing

When local ptrace policy denies GDB tracing its child, the USDT prerequisite check passes and the tests fail during node startup instead of skipping.

Location: test/functional/test_framework/test_framework.py:1025 (head).

Review coverage was incomplete.


Reviewed: ad73514cc77a · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:4d44b6ffa09c54db24f8f0ab27ae388beae06a733efcae741ca64db76bb1c938:7efd3c3ba41667382004cfa7a7db56605da7d8f9b7ab69bc483f27117390ba48 --> <!-- ralph-base:b4f341a93f1cc9e9229f5aa1ccfbb033da074f22 --> <!-- ralph-head:ad73514cc77aa22826847a6ce6335ed34a4e24d9 --> <!-- ralph-case:802ac2de4e049f95863d4799eacdf0dbba0e4a5e50d88d8bc54dd46fa995ed13 --> **🔵 Suggestion · GDB capture does not assert integer argument types** Value-preserving width changes can pass the USDT tests because capture converts arguments to Python integers without checking the documented widths or signedness. Location: [`test/functional/test_framework/usdt.py:103`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/ad73514cc77aa22826847a6ce6335ed34a4e24d9/test/functional/test_framework/usdt.py#L103>) (head). **🔵 Suggestion · Runtime probe enabling is no longer exercised** Enabling every probe before daemon initialization leaves the USDT tests unable to detect regressions specific to consumers attaching to an already-running node. Location: [`test/functional/test_framework/usdt.py:38`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/ad73514cc77aa22826847a6ce6335ed34a4e24d9/test/functional/test_framework/usdt.py#L38>) (head). **🔵 Suggestion · readelf fallback conflates multiple locations of a probe** If a probe has multiple compiled locations with different operands, the byte-register fallback can record incorrect arguments by using one location's layout for every hit. Location: [`test/functional/test_framework/usdt.py:109`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/ad73514cc77aa22826847a6ce6335ed34a4e24d9/test/functional/test_framework/usdt.py#L109>) (head). **🔵 Suggestion · USDT prerequisite check misses denied child tracing** When local ptrace policy denies GDB tracing its child, the USDT prerequisite check passes and the tests fail during node startup instead of skipping. Location: [`test/functional/test_framework/test_framework.py:1025`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/ad73514cc77aa22826847a6ce6335ed34a4e24d9/test/functional/test_framework/test_framework.py#L1025>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`ad73514cc77a`](<https://git.fish.foo/bitcoin/bitcoin/commit/ad73514cc77aa22826847a6ce6335ed34a4e24d9>) · [Full review report](<https://review.fish.foo/traces/36627-ad73514cc77aa22826847a6ce6335ed34a4e24d9-2247-3.html>) · [Previous reports](<https://review.fish.foo/traces/36627/>) [permalink](<https://review.fish.foo/traces/36627-ad73514cc77aa22826847a6ce6335ed34a4e24d9-2247-3.html>)
willcl-ark commented 2026-10-23 19:32:51 +00:00 (Migrated from github.com)

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

I beefed up the tradeoffs section here as I think it may have been undersold in its previous form.
0xB10C commented 2026-10-23 20:02:16 +00:00 (Migrated from github.com)

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 https://github.com/bitcoin/bitcoin/issues/35142#issuecomment-4959156870?

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 https://github.com/bitcoin/bitcoin/issues/35142#issuecomment-4959156870?
maflcko (Migrated from github.com) reviewed 2026-10-26 10:43:36 +00:00
maflcko (Migrated from github.com) left a comment
How does this fit into the large picture in https://github.com/bitcoin/bitcoin/issues/35142 ?
maflcko (Migrated from github.com) commented 2026-10-26 10:41:31 +00:00

remove the comment?

remove the comment?
maflcko (Migrated from github.com) commented 2026-10-26 10:41:43 +00:00

bump, like all other sanitizer tests?

bump, like all other sanitizer tests?
DrahtBot commented 2026-11-05 14:34:32 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
willcl-ark commented 2026-11-05 15:07:34 +00:00 (Migrated from github.com)

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.
> 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.
willcl-ark (Migrated from github.com) reviewed 2026-11-05 15:07:43 +00:00
willcl-ark (Migrated from github.com) commented 2026-11-05 15:07:43 +00:00

done in 89e34fbc37

done in 89e34fbc3789077b30fe9a5f38b5b0426ba76f0f
willcl-ark (Migrated from github.com) reviewed 2026-11-05 15:07:51 +00:00
willcl-ark (Migrated from github.com) commented 2026-11-05 15:07:51 +00:00

done in 89e34fbc37

done in 89e34fbc3789077b30fe9a5f38b5b0426ba76f0f
willcl-ark commented 2026-11-05 15:31:48 +00:00 (Migrated from github.com)

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.

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 commented 2026-11-11 20:50:59 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36627
No description provided.