symbolic icon indicating copy to clipboard operation
symbolic copied to clipboard

The hack for #291 breaks reading DWARF line info from .o files

Open glandium opened this issue 3 years ago • 5 comments

Environment

Steps to Reproduce

  1. cargo new testcase
  2. cd testcase
[package]
name = "testcase"
version = "0.1.0"
edition = "2021"
[dependencies]
symbolic-debuginfo = "8"
EOF
cat > src/main.rs <<EOF
use std::io::Read;

fn main() {
    for file in std::env::args().skip(1) {
        let mut data = Vec::new();
        std::fs::File::open(file)
            .unwrap()
            .read_to_end(&mut data)
            .unwrap();
        for f in symbolic_debuginfo::Object::parse(&data)
            .unwrap()
            .debug_session()
            .unwrap()
            .functions()
        {
            println!("{:#?}", f);
        }
    }
}
EOF
  1. curl -Lo mac-normal.o https://github.com/mozilla/fix-stacks/blob/master/tests/mac-normal.o?raw=true
  2. cargo run mac-normal.o

Expected Result

Two Functions printed, both with LineInfos.

Actual Result

Only one of them has LineInfo.

Reverting the hack for #291 (c13ac5c577bfecfd19480ea0a2633d5eb10c13c4) fixes it.

What's worth noting is that while reading DWARF info from mach-o objects generally works except for this, DWARF info from ELF objects is even more broken:

cat > foo.c <<EOF
int foo() {
       	return 42;
}

int bar() {
       	return 42;
}
EOF
gcc -o foo.o -c foo.c -g
cargo run foo.o

displays only one Function, without LineInfos.

cat > bar.c <<EOF
int foo() {
       	return 42;
}

void bar() {
}
EOF
gcc -o bar.o -c bar.c -g
cargo run bar.o

displays two Functions, without LineInfos, both with the name foo.

I presume this is because in the former case, both functions have the same (address, size).

glandium avatar Dec 17 '21 07:12 glandium

I presume this is because in the former case, both functions have the same (address, size).

It is worth noting that dwarfdump shows different addresses for the functions, but not the info the testcase prints.

glandium avatar Dec 17 '21 08:12 glandium

We don't know when we'll get around to fixing this. Can you run off a fork in the meantime?

loewenheim avatar Dec 20 '21 09:12 loewenheim

What's your time frame? It's been busted on our end since we upgraded to version 8, which was almost a year ago, so a few weeks is not going to make a huge difference.

glandium avatar Dec 21 '21 04:12 glandium

It's probably gonna take us a while.

loewenheim avatar Dec 21 '21 14:12 loewenheim

Maybe one option would be to allow zero addresses for relocatable objects, similar to what's done here: https://github.com/getsentry/symbolic/blob/6711360964fc7ae09e59e77108834bfa8ef4ee9a/symbolic-debuginfo/src/dwarf.rs#L487-L489

mstange avatar Aug 03 '22 19:08 mstange

This issue is stale. Closing. Please reopen if necessary.

jernejstrasner avatar Dec 06 '23 18:12 jernejstrasner

This still is an issue, but there is no option to reopen.

glandium avatar Dec 06 '23 20:12 glandium