coz icon indicating copy to clipboard operation
coz copied to clipboard

`dwarf::format_error` when running rust program

Open appetrosyan opened this issue 3 years ago • 9 comments

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

appetrosyan avatar Jan 19 '22 09:01 appetrosyan

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.

bjorn3 avatar Jan 19 '22 14:01 bjorn3

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

antoyo avatar Mar 09 '22 17:03 antoyo

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

PSeitz avatar Jun 01 '22 09:06 PSeitz

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!

flber avatar Jan 29 '23 22:01 flber

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

matheus-consoli avatar Jul 28 '23 02:07 matheus-consoli

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

Alizter avatar Nov 16 '23 18:11 Alizter

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?

ysfess22 avatar Mar 05 '24 14:03 ysfess22

@ysfess22 No unfortunately not.

Alizter avatar Mar 05 '24 15:03 Alizter

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?

camelid avatar Mar 13 '24 18:03 camelid