-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Disable a symbol name cache if ASLR is enabled #1033
Conversation
I do not like the mid output errors, makes it visually very messy. The errors aren't really informative either, it is just a confusing way of telling people that the process has exited before the stackframe was symbolized. I think it is better to aggregate them and print them last, skipping ENOENT. Or just skip them at all.
We should measure this, I can't imagine it being "cheap" for the larger binaries. Although I do not know what tricks bcc has, they might have some tricks to speed it up. I think we should make this thing optional with a flag that accepts:
|
I feel the same. I'm thinking about making output only when I'll look into the overhead. By the way, we can use |
This is the result of the simple benchmark.
Time increases proportionally if the cache is disabled. |
8ebfa37
to
a063901
Compare
I made the following changes.
|
a063901
to
5bbd3b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @dxu @mmarchini objections?
( This should probably moved out of bpftrace as some point, #1080 )
5bbd3b4
to
94f85d3
Compare
… given `resolve_usym()` caches a `bcc_symbol` object using an executable name as a key, but on the ASLR-enabled platform, symbol addresses change with each execution. Disable (discard) a cache, in this case, to resolve symbol names properly. Introduce `BPFTRACE_CACHE_USER_SYMBOLS` env variable to force caching. Caching is fine if only trace one program execution. Note and known issues: - A cache is discarded whenever resolve_usym is called even if a pid is the same as the old one. This is because pid may be reused. - This does not check whether a binary is PIE ASLAR or not. Note that even if a binary is not PIE ASLR, addresses of shared libraries are randomized if ASLR is enabled. (If a binary is not PIE ASLR and `resolve_usym()` resolves symbol in a binary, we can utilize a cache.) - If ASLR is disabled on the first execution but enabled on the second execution, `resolve_usym()` for the second run will use the previous cache. - As discussed in bpftrace#246, symbolizing will fail after process termination (this is a separate issue). For example: ``` % bpftrace -e 'u:/lib/x86_64-linux-gnu/libc.so.6:*nanosleep* /comm == "sleep"/ { @[ustack] = count(); }' Attaching 7 probes... ^C @[ 0x7ff1917cb990 ]: 3 @ [ 0x7fea4211c990 ]: 3 @ [ 0x7f32bc51a990 ]: 3 ``` ----- Closes bpftrace#1031 and solves the second part of bpftrace#75.
94f85d3
to
ce50e3e
Compare
LGTM |
resolve_usym()
caches abcc_symbol
object using an executable nameas a key, but on the ASLR-enabled platform, symbol addresses change with
each execution. Disable (discard) a cache, in this case, to resolve
symbol names properly.
Note and known issues:
the same as the old one. This is because pid may be reused.
even if a binary is not PIE ASLR, addresses of shared libraries are
randomized if ASLR is enabled. (If a binary is not PIE ASLR and
resolve_usym()
resolves symbol in a binary, we can utilize a cache.)execution,
resolve_usym()
for the second run will use the previouscache.
huge, maybe this should be an option.
(this is a separate issue). For example:
Closes #1031 and solves the second part of #75.