Skip to content

Commit 953c90d

Browse files
committed
Merge bitcoin/bitcoin#33086: contrib: [tracing] fix pointer argument handling in mempool_monitor.py
0ce041e tracing: fix pointer argument handling in mempool_monitor.py (deadmanoz) Pull request description: The BPF code was incorrectly passing pointer variables by value to `bpf_usdt_readarg()`, causing the function to fail silently and resulting in transaction hashes showing as zeros and reason strings displaying empty strings. This fix adds the missing reference operator (&) when passing pointer variables to `bpf_usdt_readarg()`, allowing the function to properly write the pointer values and enabling correct display of transaction hashes and removal/rejection reasons. Fixes the regression introduced in [ec47ba3](bitcoin/bitcoin@ec47ba3) where `bpf_usdt_readarg_p` was replaced with `bpf_usdt_readarg` but the calling convention wasn't properly updated for pointer arguments. **Before: "0000000000000000000000000000000000000000000000000000000000000000" tx hashes, and missing reasons (empty strings) for removal.** <img width="1683" height="1330" alt="Screenshot 2025-07-29 at 4 30 03 PM" src="https://github.com/user-attachments/assets/71ba88be-dbcc-43a6-bfe7-bd49ae082b13" /> **After: tx hashes show, reasons for removal showing.** <img width="1682" height="1330" alt="Screenshot 2025-07-29 at 4 29 23 PM" src="https://github.com/user-attachments/assets/03738c75-5526-4c1e-82c2-ba100cdf128a" /> ACKs for top commit: 0xB10C: tested ACK 0ce041e Tree-SHA512: cb50748fa2cd38be4b0abed36723917c2c82a92f588928bb0650eed0049c121df89b33d53421037b12836a497f30b449fe3d041ff7755a1fd9da43544392cf40
2 parents 3724e9b + 0ce041e commit 953c90d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

contrib/tracing/mempool_monitor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
int trace_added(struct pt_regs *ctx) {
6767
struct added_event added = {};
6868
void *phash = NULL;
69-
bpf_usdt_readarg(1, ctx, phash);
69+
bpf_usdt_readarg(1, ctx, &phash);
7070
bpf_probe_read_user(&added.hash, sizeof(added.hash), phash);
7171
bpf_usdt_readarg(2, ctx, &added.vsize);
7272
bpf_usdt_readarg(3, ctx, &added.fee);
@@ -78,9 +78,9 @@
7878
int trace_removed(struct pt_regs *ctx) {
7979
struct removed_event removed = {};
8080
void *phash = NULL, *preason = NULL;
81-
bpf_usdt_readarg(1, ctx, phash);
81+
bpf_usdt_readarg(1, ctx, &phash);
8282
bpf_probe_read_user(&removed.hash, sizeof(removed.hash), phash);
83-
bpf_usdt_readarg(2, ctx, preason);
83+
bpf_usdt_readarg(2, ctx, &preason);
8484
bpf_probe_read_user_str(&removed.reason, sizeof(removed.reason), preason);
8585
bpf_usdt_readarg(3, ctx, &removed.vsize);
8686
bpf_usdt_readarg(4, ctx, &removed.fee);
@@ -93,9 +93,9 @@
9393
int trace_rejected(struct pt_regs *ctx) {
9494
struct rejected_event rejected = {};
9595
void *phash = NULL, *preason = NULL;
96-
bpf_usdt_readarg(1, ctx, phash);
96+
bpf_usdt_readarg(1, ctx, &phash);
9797
bpf_probe_read_user(&rejected.hash, sizeof(rejected.hash), phash);
98-
bpf_usdt_readarg(2, ctx, preason);
98+
bpf_usdt_readarg(2, ctx, &preason);
9999
bpf_probe_read_user_str(&rejected.reason, sizeof(rejected.reason), preason);
100100
rejected_events.perf_submit(ctx, &rejected, sizeof(rejected));
101101
return 0;
@@ -104,12 +104,12 @@
104104
int trace_replaced(struct pt_regs *ctx) {
105105
struct replaced_event replaced = {};
106106
void *phash_replaced = NULL, *phash_replacement = NULL;
107-
bpf_usdt_readarg(1, ctx, phash_replaced);
107+
bpf_usdt_readarg(1, ctx, &phash_replaced);
108108
bpf_probe_read_user(&replaced.replaced_hash, sizeof(replaced.replaced_hash), phash_replaced);
109109
bpf_usdt_readarg(2, ctx, &replaced.replaced_vsize);
110110
bpf_usdt_readarg(3, ctx, &replaced.replaced_fee);
111111
bpf_usdt_readarg(4, ctx, &replaced.replaced_entry_time);
112-
bpf_usdt_readarg(5, ctx, phash_replacement);
112+
bpf_usdt_readarg(5, ctx, &phash_replacement);
113113
bpf_probe_read_user(&replaced.replacement_hash, sizeof(replaced.replacement_hash), phash_replacement);
114114
bpf_usdt_readarg(6, ctx, &replaced.replacement_vsize);
115115
bpf_usdt_readarg(7, ctx, &replaced.replacement_fee);

0 commit comments

Comments
 (0)