Skip to content
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

Error: failed to open BPF object file: Relocation failed #6

Closed
NGUETOUM opened this issue Jan 16, 2022 · 2 comments
Closed

Error: failed to open BPF object file: Relocation failed #6

NGUETOUM opened this issue Jan 16, 2022 · 2 comments

Comments

@NGUETOUM
Copy link

NGUETOUM commented Jan 16, 2022

Good Morning,
I've compiled the kernel and replaced my previous kernel in my ubuntu, then when using the command sudo bazel build -c opt ... to compile ghost-userspace, I got this error:

ERROR: /home/armel/Desktop/ghost/ghost-userspace/BUILD:455:13: Executing genrule //:schedghostidle_bpf_skel failed: (Exit 255): bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
libbpf: prog 'sched_ghost_latched': invalid relo against 'nr_latches' in special section 0xfff2; forgot to initialize global var?..
Error: failed to open BPF object file: Relocation failed
INFO: Elapsed time: 192.466s, Critical Path: 3.28s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully

The version of ghost-kernel that I am using is 5.11.0+ and i am using Ubuntu 20.04.
Please someone can help me to solve this problem ?

@NGUETOUM
Copy link
Author

Good Morning,
I am very sorry to disturb you but I have found the solution to my problem. To solve that issue I have just initialize some variable in
the following file : third_party/bpf/schedghostidle.bpf.c.
In that file I have just initialize the following variable:
uint64_t nr_latches = 0;
uint64_t nr_bpf_latches = 0;
uint64_t nr_idle_to_bpf_latches = 0;

Excuse me and thanks for your comprehension.

@jackhumphries
Copy link
Collaborator

Fixed in #7.

hannahyp pushed a commit that referenced this issue Mar 18, 2022
Specifically the bug is that we are depending on the initialization of
GHOST_TID_SEQNUM_BITS (in base.cc) during the initialization of another
global Agent::kVersionCheck (in agent.cc). Since there is no ordering
across compilation units this can result in accessing GHOST_TID_SEQNUM_BITS
before it has been initialized.

READ of size 4 at 0x7ff981751180 thread T0
    #0 0x7ff98134368f in ghost::gtid(long) third_party/ghost/lib/base.cc:122:19
    #1 0x7ff98134196d in GetGtid third_party/ghost/lib/base.cc:212:28
    #2 0x7ff98134196d in Current third_party/ghost/lib/base.h:164:40
    #3 0x7ff98134196d in ghost::Exit(int) third_party/ghost/lib/base.cc:285:28
    #4 0x7ff981b93db4 in ghost::Ghost::MountGhostfs() third_party/ghost/lib/ghost.cc:147:5
    #5 0x7ff981b93fe5 in ghost::Ghost::GetSupportedVersions(std::__u::vector<unsigned int, std::__u::allocator<unsigned int> >&) third_party/ghost/lib/ghost.cc:155:5
    #6 0x7ff982102744 in ghost::Ghost::CheckVersion() third_party/ghost/lib/ghost.h:274:5
    #7 0x7ff98217c564 in __cxx_global_var_init third_party/ghost/lib/agent.cc:102:35
    #8 0x7ff98217c564 in _GLOBAL__sub_I_agent.cc third_party/ghost/lib/agent.cc
    #9 0x7ff9cc37b4cc in call_init (/usr/grte/v5/lib64/ld-linux-x86-64.so.2+0x1c4cc)
    #10 0x7ff9cc37b329 in _dl_init (/usr/grte/v5/lib64/ld-linux-x86-64.so.2+0x1c329)

Fix this by caching the result in a function-local static variable in
get_tid_seqnum_bits() which is guaranteed to be initialized the first time
it is accessed, and this initialization will happen before any other access.

TESTED=all units tests pass in virtme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants