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

Miscompilation issue / problem with perf - addr2line: could not read first record #2394

Open
2 tasks done
Fogapod opened this issue Apr 19, 2024 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@Fogapod
Copy link

Fogapod commented Apr 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I tried recording perf data for my program and it fails at perf script stage. I am not sure if this might be rustc or linux/perf issue but I only have it with iced. I later confirmed same behaviour on clock and websocket examples.

Steps to reproduce:

$ cd examples/clock

$ CARGO_PROFILE_RELEASE_DEBUG=true CARGO_PROFILE_RELEASE_STRIP=false cargo build --release
    Finished release [optimized   debuginfo] target(s) in 28.81s

$ perf record --call-graph dwarf -- ../../target/release/clock
[ perf record: Woken up 21 times to write data ]
[ perf record: Captured and wrote 8.437 MB perf.data (1025 samples) ]

$ perf script | inferno-collapse-perf > stacks.folded
addr2line /home/eugene/.debug/.build-id/62/bb8c63e30c190e024807d25ce0aeeaa64078f2/elf: could not read first record
addr2line /home/eugene/.debug/.build-id/62/bb8c63e30c190e024807d25ce0aeeaa64078f2/elf: could not read first record
addr2line /home/eugene/.debug/.build-id/62/bb8c63e30c190e024807d25ce0aeeaa64078f2/elf: could not read first record

$ file /home/eugene/.debug/.build-id/62/bb8c63e30c190e024807d25ce0aeeaa64078f2/elf
/home/eugene/.debug/.build-id/62/bb8c63e30c190e024807d25ce0aeeaa64078f2/elf: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 4.4.0, BuildID[sha1]=62bb8c63e30c190e024807d25ce0aeeaa64078f2, with debug_info, not stripped

perf script loops forever with this addr2line error.

Environment:

OS: up to date Arch Linux
CPU: AMD Ryzen 9 5950X
rust: rustc 1.77.2 (25ef9e3d8 2024-04-09)
iced: both master and latest release

Some things I tried:

  • this happens on both debug and release
  • removing target/ and ~/.debug does not help
  • fn main() { loop {} } does not trigger error
  • this happens both with and without mold linker
  • this happens without any extra rustc flags like cpu-target=native

What is the expected behavior?

perf script to complete successfully

Version

master

Operating System

Linux

Do you have any log output?

No response

@Fogapod Fogapod added the bug Something isn't working label Apr 19, 2024
@SL-RU
Copy link

SL-RU commented Jun 9, 2024

You need to install and use latest version of addr2line

cargo install  addr2line --features="bin" 
PATH=$HOME/.cargo/bin:$PATH

@marxin
Copy link

marxin commented Jun 28, 2024

I've reached the very same issue and I investigated what's wrong. If you have perf 6.5 , then it's a version that suffers from a slow binutils addr2line as described here: https://bugzilla.kernel.org/show_bug.cgi?id=218996. And as suggested, it's something one can fix by using the Rust implementation of addr2line binary that is much faster and does not hit the 1s timeout used by perf. In any case, the error message provided by perf is not ideal and should be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants