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

Does not work on binaries linked with mold #1951

Open
tumanovm opened this issue Aug 20, 2024 · 2 comments
Open

Does not work on binaries linked with mold #1951

tumanovm opened this issue Aug 20, 2024 · 2 comments

Comments

@tumanovm
Copy link

tumanovm commented Aug 20, 2024

Hello!

When I tried to use uftrace 0.16 in project I noticed that it does not work on binaries linked with mold. It works fine when linking with gold in the same environment, so I've tried to make a minimal example for you.

I attached an archive with a Dockerfile and a couple of shell scripts for your convinience.
uftrace-mold.tar.gz

Here is a short overview:

  • Extract contents somewhere and cd into directory
  • Use ./build-image.sh to build image (then ./remove-image.sh later to clean up your environment)
  • Use ./in-container.sh <COMMAND> to run command inside container as if your working directory is project (For example ./in-container.sh make <TARGET>)
  • See project/Makefile to learn and edit compile command and uftrace record command
  • Use ./in-container.sh make record to compile a simple hello world executable and run uftrace record on it
  • See project/output directory to find uftrace log file and uftrace.data directory

Instead of getting "Hello world!" message in stdout when running ./in-container.sh make record, uftrace exits with code 2 and uftrace.log contains this message:
WARN: child terminated by signal: 5: Trace/breakpoint trap

Environment:

  • uftrace 0.16
  • gcc 13.2
  • mold 2.33.0

Thanks for the great tool. It is very helpful and convinient!

@tumanovm
Copy link
Author

When running uftrace on a real executable linked with mold I could find these lines in log:

WARN: Segmentation fault: address not mapped (addr: 0x1)
WARN: Backtrace from uftrace  ( x86_64 dwarf perf sched )
WARN: =====================================
WARN: [0] (OPENSSL_cpuid_setup[55963b1b17c0] <= <559639f4e92b>[559639f4e92b])
uftrace: MSG START: /uftrace-6de1a0c1d3f49a0b-60-000
uftrace: MSG TASK_START : 60/60
uftrace: all process/thread exited
WARN: child terminated by signal: 11: Segmentation fault

After switching linker from mold to gold there are no such lines in log and everything works as expected

@namhyung
Copy link
Owner

Thanks for the report. I've never tried mold linker by myself yet, but it looks like a cool project. I'll take a look what difference it caused the trouble.

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