-
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
Fix symbol resolution across mount namespaces (#2029) #2030
Conversation
std::string exe = ebpf::get_pid_exe(pid_); | ||
Module module(exe.c_str(), mount_ns_instance_.get(), &symbol_option_); | ||
|
||
if (module.type_ != ModuleType::EXEC) | ||
return; | ||
|
||
ProcMountNSGuard g(mount_ns_instance_.get()); | ||
|
||
bcc_elf_foreach_load_section(exe.c_str(), &_add_load_sections, &module); |
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.
We have to move to mount namespace before accessing the file /proc/pid/exe file.
@@ -163,6 +163,7 @@ int ProcSyms::_add_module(const char *modname, uint64_t start, uint64_t end, | |||
// It only gives the mmap offset. We need the real offset for symbol | |||
// lookup. | |||
if (module.type_ == ModuleType::SO) { | |||
ProcMountNSGuard g(ps->mount_ns_instance_.get()); |
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.
Ditto. Migrate to task's mount namespace before accessing the symbol file.
@tekumara could you check whether this fixed your issue (#1990)? |
Using this PR, I run
|
@tekumara - You don't have to run bcc inside of a container. Can you try profiling the process using the default namespace pid and check if it works ? |
@vijunag do you mean running bcc from the host? I've tried running bcc (compiled with this PR) on the host (ie: not in a container) and it produces the same output as above. |
@tekumara - Are your Java shared objects compiled with frame pointers ? If no, then the problem is not related to this issue. |
@vijunag I've installed the jdk8 debug symbols into the container and now I'm not getting I've also created a java perf map and am now getting TL;DR - all good, thankyou! |
[buildbot, test this please] |
@palmtenor any opinion? Will this work for the case to trace a process running inside the container but user provided a host file path? |
Yeah this LGTM. Thanks for the fix! |
Test - Performed a test by running bcc/tools/profile on a PID running in a container and found the resolution to be working fine.
`#define _GNU_SOURCE
#include <link.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/auxv.h>
#include <string.h>
int len;
int baz()
{
int i=0;
char a[8192], b[8192];
label:
for(i=0;i<10000;++i) {
memcpy(a,b,len);
}
goto label;
}
int foo()
{
baz();
}
int bar()
{
foo();
}
int main(int argc, char **argv)
{
printf("Start profiling\n");
len=8192;
bar();
return 1;
}`
python profile -U -p 26966 1
Sampling at 49 Hertz of PID 26966 by user stack for 1 secs.
warning: JITed object file architecture unknown is not compatible with target architecture i386:x86-64.