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

thread 'main' panicked at 'BUG: callee XYZ is unknown' / (minimally) handle dynamically linked binaries #61

Open
japaric opened this issue Jun 22, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@japaric
Copy link
Owner

japaric commented Jun 22, 2022

dynamically linked binaries contain 'undefined' symbols

$ file hello
hello: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2

$ nm -CSn hello
                 U abort@GLIBC_2.2.5
                 U bcmp@GLIBC_2.2.5
                 U calloc@GLIBC_2.2.5
(..)

these symbols are provide at runtime by a dynamic linker (e.g. /lib/ld-linux.so.2). Therefore cargo-call-stack, a static analysis tool, cannot provide a complete call graph for these kind of binaries.

Currently cargo-call-stack panics when it sees these kind of binaries. We should more gracefully handle these binaries by adding a dummy node that represents the dynamic libraries provided by the environment (dynamic linker) to the call graph and having all calls into 'undefined' symbols be connected to that dummy node.

It's not possible to provide a max stack usage number for dynamically linked binaries so that should also be reported to the console.

Workaround

If you are hitting the "thread 'main' panicked at 'BUG: callee XYZ is unknown'" error message try using a compilation target that produces a statically linked binary. If you were using x86_64-unknown-linux-gnu then use x86_64-unknown-linux-musl.

@japaric japaric added the enhancement New feature or request label Jun 22, 2022
@japaric japaric pinned this issue Jun 22, 2022
@japaric japaric changed the title (minimally) handle dynamically linked binaries / AKA thread 'main' panicked at 'BUG: callee XYZ is unknown' thread 'main' panicked at 'BUG: callee XYZ is unknown' / (minimally) handle dynamically linked binaries Jun 23, 2022
@ryankurte
Copy link

it seems this also occurs with static binaries when using build-std with compiler_builtins and build-std-features = ["compiler-builtins-mem"] (without which i get panicked at 'compiler_builtins' LLVM IR unavailable')?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants