Re: [iovisor/bcc] USDT broken by b0f891d129a9b372

Yonghong Song

Hi, Tetsuo,

You are right. The bug is actually introduced by my last patch. I just
focused one aspect of issue and inadvertently introduced another
*blocker* bug.

I just pushed a patch. Thanks a lot for reporting the issue and
testing out the fix.


On Mon, Jun 5, 2017 at 5:25 PM, Tetsuo Handa
<penguin-kernel@...> wrote:

I changed the hook as below and confirmed that cp == NULL at bpf_probe_read().
That is, it is bpf_usdt_readarg() which got broken.

int do_start(struct pt_regs *ctx) {
char *cp = NULL;
bpf_usdt_readarg(1, ctx, &cp);
struct { char query[QUERY_MAX]; } data = { };
if (cp != NULL)
bpf_probe_read(&data.query, sizeof(data.query), (void *) cp);
data.query[0] = '!';
events.perf_submit(ctx, &data, sizeof(data));
return 0;

If I do

- std::string cptr = tfm::format("*((volatile %s *)dest)", ctype);
+ std::string cptr = tfm::format("*((%s *)dest)", ctype);

(i.e. drop only "volatile " part) in that commit like below

diff --git a/src/cc/ b/src/cc/
--- a/src/cc/
+++ b/src/cc/
@@ -152,7 +152,7 @@ bool Probe::usdt_getarg(std::ostream &stream) {

for (size_t arg_n = 0; arg_n < arg_count; ++arg_n) {
std::string ctype = largest_arg_type(arg_n);
- std::string cptr("dest");
+ std::string cptr = tfm::format("*((%s *)dest)", ctype);

"static __always_inline int _bpf_readarg_%s_%d("

USDT probe works again as well as build warning shown below goes away.

/virtual/main.c:4:8: warning: incompatible integer to pointer conversion assigning to 'void *' from 'volatile uint64_t' (aka 'volatile unsigned long long') [-Wint-conversion]
dest = *(volatile uint64_t *)&ctx->bx;
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Join { to automatically receive all group messages.