-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracing USDTs in executables compiled with -pie #1998
Comments
@zilder : Good debugging! Here are some ideas:
|
@palmtenor |
Cool, other than |
Ok, values within
Result of
Contents of
Results of
|
OK, looks like we used the first loaded section of the file, where what we should actually be doing is to find the section that the offset is actually in. I can try fix that. Meanwhile should it be |
FWIW, we hit this in bpftrace as well: bpftrace/bpftrace#75 |
@zilder , can you try if following patch works?
|
FWIW, we're seeing something perhaps related on Fedora 29, there the patch proposal didn't solve that issue. See https://bugzilla.redhat.com/show_bug.cgi?id=1634684. Thanks. |
@palmtenor, patch applied but doesn't work. The condition in
|
I kind of understand the issue with Python, but not quite with the one @zilder provided since it doesn't have a load offset that would make current calculation incorrect. Regardlessly I'll try to put up a patch to fix some known issue including missing out non-executable sections and load offset, and we can see if that fixes the issue or there are more things to be discovered. |
@palmtenor,
it is
while it actually should be calculated as:
There is a patch:
It solved the problem for me. But I haven't yet tested it with shared libraries. @brendangregg, @myllynen, If it works, I'll create a pull request. Thanks! |
I'm happy to confirm this fixes the issue on Fedora 29! Thanks a lot! |
Thanks @zilder could you send a pull request? Looks like the change is good? |
@myllynen, thanks for testing! @yonghong-song, done. |
…tables (resolves iovisor#1998) (iovisor#2023) Fix USDT semaphore address calculation for position independent executables
Hi,
I have a problems tracing tracepoints in postgres built with
-pie
flag. This is how postgres is configured:I can see tracepoints embedded using
readelf
. Let's say I want to trace transaction start event.There is a simple script I use to trace event:
When I run script I get this (output was truncated):
32737 here is the PID of postgres backend that handles connection from
psql
in a separate terminal. Sobcc
can see those probes in executable, but none of transactions were actually traced. And note that enumerate_active_probes() doesn't return any probes.I inspected
bcc
withgdb
and found two things inenable_probe
call.in_shared_object()
returns true even though it is an executable binary file.readelf
shows the same thing:Apparently, compiling executable with
-pie
makes it shared object. I'm not sure how to calculate actual address of semaphore in position independent executable (I would appreciate if you could share some good article about it). That leads to...bcc_resolve_global_address()
and then try to read it from the running process inadd_to_semaphore()
and getEIO
error here:It seems that
bcc_resolve_global_address()
returns incorrect address. (Btw, maybe it makes sense to print some kind of warning if we failed to increment semaphore).On the other hand if executable was built with
-no-pie
that it works fine:And it also has EXEC type:
I'm not sure if this is a bug of bcc or I just miss something and do something wrong. If you need more information from me I'd be happy to assist.
The text was updated successfully, but these errors were encountered: