plasma-umass / coz

Coz: Causal Profiling
Other
4.03k stars 160 forks source link

`dwarf::format_error` when running rust program #193

Open appetrosyan opened 2 years ago

appetrosyan commented 2 years ago

I'm trying to add tracing-coz to a program I'm working on. As specified in the docs, I'm building with CARGO_PROFILE_RELEASE_DEBUG=true, but that causes the following error:

[libcoz.cpp:100] bootstrapping coz
[libcoz.cpp:128] Including MAIN, which is /mnt/Archive/Git/iroha/target/release/examples/million_accounts_genesis
terminate called after throwing an instance of 'dwarf::format_error'
what():  unknown compilation unit version 5
bjorn3 commented 2 years ago

Probably a duplicate of https://github.com/plasma-umass/coz/issues/107. According to https://github.com/plasma-umass/coz/issues/107#issuecomment-1007702715 passing -C link-arg=-gdwarf-3 to rustc may work.

antoyo commented 2 years ago

I added partial support for Dwarfv5 in my libelfin fork and that seems to fix this issue.

PSeitz commented 2 years ago

link-arg did not work for me, but using the libelfin fork

coz_async git:(master) ✗ RUSTFLAGS='-C link-arg=-gdwarf-3' cargo build --release
    Finished release [optimized + debuginfo] target(s) in 0.01s
➜  coz_async git:(master) ✗ coz run --- ./target/release/coz_async
[libcoz.cpp:100] bootstrapping coz
[libcoz.cpp:128] Including MAIN, which is /home/pascal/LinuxData/Development/coz_async/target/release/coz_async
terminate called after throwing an instance of 'dwarf::format_error'
  what():  unknown compilation unit version 5

after running make in /path_to_libelfin/

LD_LIBRARY_PATH=/path_to_libelfin/dwarf coz run --- ./target/release/coz_async
[libcoz.cpp:100] bootstrapping coz
[libcoz.cpp:128] Including MAIN, which is /home/pascal/LinuxData/Development/coz_async/target/release/coz_async
[inspect.cpp:513] Ignoring DWARF format error when reading line table: unknown line number table version 5
[inspect.cpp:513] Ignoring DWARF format error when reading line table: unknown attribute form (DW_FORM)0x21
[inspect.cpp:513] Ignoring DWARF format error when reading line table: unknown attribute form (DW_FORM)0x1f
[inspect.cpp:513] Ignoring DWARF format error when reading line table: unknown line number table version 5
[inspect.cpp:509] Included source file /home/pascal/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/park/either.rs
flber commented 1 year ago

I'm also having the same problem. The output of my program is

[libcoz.cpp:100] bootstrapping coz
[libcoz.cpp:128] Including MAIN, which is /home/benh/projects/pillar/target/release/pillar
terminate called after throwing an instance of 'dwarf::format_error'
  what():  unknown compilation unit version 5

I've tried adding the compiler flags suggested by @bjorn3 to my .cargo/config.toml file like so

[build]
rustflags = ["-C", "link-args=-gdwarf-3"]

which fails to fix the issue (and doesn't change the output).

I'm a little bit unsure about how I would use the other suggestions (libelfin?), so any clarification would be great!

matheus-consoli commented 1 year ago

Hi, I just stepped into this problem!

Just to add to the future readers, you have to tell rustc to generate the specific dwarf version coz is trying to read, so in my case (and everyone in this thread, I guess), I had to pass dwarf-5:

RUSTFLAGS="-C link-arg=gdwarf-5" coz run --- ./target/release/something

Alizter commented 9 months ago

Is there something that can be done within coz about this? I'm running into similar issues and my setup is not rust specific.

ysfess22 commented 5 months ago

Hi, @Alizter I'm running into the same error and my setup is not specific to rust either. Were you able to find a solution?

Alizter commented 5 months ago

@ysfess22 No unfortunately not.

camelid commented 5 months ago

Hi @ysfess22 @Alizter do you happen to have a small test case that reproduces this error? Or could you provide more information about your setup?