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

rbpf_cli hangs loading a shared library file #166

Closed
vakond opened this issue May 14, 2021 · 3 comments · Fixed by #167
Closed

rbpf_cli hangs loading a shared library file #166

vakond opened this issue May 14, 2021 · 3 comments · Fixed by #167

Comments

@vakond
Copy link

vakond commented May 14, 2021

This command:

rbpf_cli --use disassembler --elf spl_token-3.1.0.so

takes forever to complete with CPU usage = 100%.

The latest rbpf main branch had been used. The input file's location: https://github.com/solana-labs/solana/blob/master/program-test/src/programs/spl_token-3.1.0.so

@vakond
Copy link
Author

vakond commented May 14, 2021

One can attach a debugger and see the program spends time searching something. Looks like it entered a forever loop.

* thread #1, name = 'rbpf_cli', stop reason = signal SIGSTOP
    frame #0: 0x000055c2b033011c rbpf_cli`alloc::collections::btree::search::_$LT$impl$u20$alloc..collections..btree..node..NodeRef$LT$BorrowType$C$K$C$V$C$Type$GT$$GT$::find_key_index::h6a386a2ad93b0899(self=0x00007ffe74b82f10, key=0x00007ffe74b83308) at search.rs:206:17
   203          let keys = node.keys();
   204          for (i, k) in keys.iter().enumerate() {
   205              match key.cmp(k.borrow()) {
-> 206                  Ordering::Greater => {}
   207                  Ordering::Equal => return IndexResult::KV(i),
   208                  Ordering::Less => return IndexResult::Edge(i),
   209              }

Executable module set to "target/debug/rbpf_cli".
Architecture set to: x86_64-pc-linux-gnu.

@vakond
Copy link
Author

vakond commented May 14, 2021

rustup show

Default host: x86_64-unknown-linux-gnu

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
bpf

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.52.1 (9bc8c42bb 2021-05-09)

@Lichtso
Copy link

Lichtso commented May 17, 2021

Thanks for the detailed bug report!

It was indeed an infinite loop caused by an impossible CFG. Which in turn was caused by a leading unreachable exit instruction at the beginning of the program, shifting all basic blocks of the first function by one.

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

Successfully merging a pull request may close this issue.

2 participants