FATAL: BUG: Struct size mismatch: #2023
-
What I was trying to do is that hook glibc printf and puts and then print its first argument whenever the prove is triggered. However if I run this, I get this error message what did I do wrong? struct size mismatch...? I have no idea.. thanks..! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The problem is the size of (The difference comes from the fact that type of A workaround is using |
Beta Was this translation helpful? Give feedback.
The problem is the size of
""
is 64 (STRING_SIZE) but the size ofcomm
is 16 (COMM_SIZE).https://github.com/iovisor/bpftrace/blob/45d23c82c36d2467e322e96b532edee33720c997/src/ast/passes/semantic_analyser.cpp#L97 https://github.com/iovisor/bpftrace/blob/45d23c82c36d2467e322e96b532edee33720c997/src/ast/passes/semantic_analyser.cpp#L346
(The difference comes from the fact that type of
""
ischar *
but thecomm
is `char[16].)A workaround is using
comm
instead of""
in theBEGIN{}
.sudo bpftrace -e 'BEGIN {@prev = (comm,"")} u:/usr/lib/libc.so.6:printf,u:/usr/lib/libc.so.6:puts / @prev != (comm, str(arg0)) / { printf("%s %s: %s\n", probe, comm, str(arg0)); @prev = (comm, str(arg0)) }