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
ld64.lld.darwinnew produces invalid debug info, causing lldb to err with "N_SO in symbol with UID 145239 has invalid sibling in debug map, please file a bug and attach the binary listed in this error" #48058
Comments
assigned to @int3 |
Seems like fixing the function size calculation didn't address this problem. I will investigate this soonish. |
Subscribing Greg Clayton in case he has ideas. |
So LLDB, when parsing a symbol table, will look for N_SO symbols and it tries to match up a N_SO symbol with a name (source path) to the N_SO symbol without a name. So for this binary: $ dsymutil -s a.outSymbol table for: 'a.out' (x86_64)Index n_strx n_type n_sect n_desc n_value LLDB will simplify the symbol table like so: (lldb) image dump symtab a.out [ 0] 1 D SourceFile 0x0000000000000000 Sibling -> [ 3] 0x00640000 /Users/gclayton/Documents/src/args/main.cpp Note that the UserID column refers to the original symbol index. Since the mach-o symbol table has so many duplicate symbol entries for something (like '_main' is described by symbols 5, 6 and 10, but LLDB will make only a single symbol for it in the symbol table that LLDB uses. We see that the first symbol represents the N_SO: It points to a sibling symbol (as we see from "Sibling -> [ 3]"), or the first symbol that doesn't belong to the N_SO. This lets us simplify the symbol table that LLDB uses, but it still maintains the original scoping where all symbols from the first N_SO with a path and the last N_SO with no name create a scope where everything inside belongs to the source file. So a few things could cause this:
|
Ohhh. Our intended N_SOs with no name had a string index of zero, but because of D89639, it meant that they were pointing to a string with a single space, rather than an empty string. This was not at all obvious with llvm-nm because it doesn't quote strings, so a single space is indistinguishable from the empty string. But it's a lot more obvious with Thanks Greg!! |
The reason I originally wrote "dsymutil -s" in the first dsymutil was so I could see exactly what was in the mach-o symbol table and the quotes helped way back when. Glad you figured it out from my explanation! |
mentioned in issue #48803 |
Extended Description
Known issue, but I figured I'd file a bug so that I can link to it. Possible repro, extracted from #48001 #c5 (there are likely way smaller repros):
Download https://drive.google.com/file/d/1thKfcfKUMhyJ22HRSjorIKZjH42k3bnZ/view?usp=sharing (warning: large, 1GB compressed, 5.3GB unzipped -- but it links very quickly, less than a second with both linkers).
Link as usual (
ld64.lld.darwinnew @​response.txt
)Run like e.g. so:
lldb -- ./mksnapshot --turbo_instruction_scheduling --target_os=mac --target_arch=x64 --embedded_src embedded.S --embedded_variant Default --random-seed 314159265 --startup_blob snapshot_blob.bin --native-code-counters --verify-heap
When loading the lld-linked binary into lldb, it prints many lines looking like
error: mksnapshot N_SO in symbol with UID 145239 has invalid sibling in debug map, please file a bug and attach the binary listed in this error
This doesn't happen with ld.
(Once this is fixed, debug info isn't terribly useful without the actual source files somewhere. Due to https://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html one has to run
settings set target.source-map ../.. actual/local/path/to/src
in lldb even if src files are available locally somewhere.)The text was updated successfully, but these errors were encountered: