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
cmd/internal/dwarf: incorrect or missing dwarf information in libstd.so on ppc64le, amd64 #20328
Comments
Same failure happens on x86. Here is the output from objdump for the dwarf info: <1>: Abbrev Number: 2 (DW_TAG_subprogram) This is only happening with DW_TAG_formal_parameter entries. I can see that DW_AT_type should not be 0 and that is what gdb doesn't like. There are lots of formal parameters that are correct in the dwarf output. If I build hello as a program using external linking but not -linkshared then the dwarf is correct and gdb works fine. |
CC @heschik |
Ian, you scared me a little before I realized this bug was 3 weeks old :) Probably not my fault then. I'm not too familiar with this, but it looks to me like debugging this program is simply a non-starter. I agree that the type offsets for many of the formal_parameters in libstd.so are bogus, but that's the least of the problems here. The actual program has no debug information at all:
Hopefully someone more familiar with the dynamically linked modes can comment on whether this is expected. Otherwise I can take a look at it. |
CC @mwhudson |
Yes, we can't generate dwarf for things that are linked against other shared libraries. We should be able to generate dwarf for libstd.so (as that doesn't link to any go shared libraries) but as you can see that's buggy. The lack of DWARF at all for the executables makes this somehow less important-seeming though. IIRC the problem with DWARF for things that link against Go was things like how to represent a global variable of a type that is defined in another shared library. I don't know enough about DWARF to know the answer, do you need to duplicate the description or can you refer to DWARF in another .so somehow? |
I hadn't noticed the hello program when building with -linkshared didn't have debug information because I mainly do low level debugging anyway so having it there doesn't matter. But that seems like a bug because the output from 'go tool compile -h' says that debug information is provided by default. I have verified that the go.o file that is being sent to the linker doesn't contain the dwarf if I use -linkshared, so it is not the linker stripping it out. As a result of this discussion I realized that I can just strip out the debug info from libstd.so and do the debugging I need so that is a good enough workaround for what I am trying to do now. The problem with the bad dwarf information was that gdb didn't work at all. In case you are curious here is the dwarf output from a program created not using -linkshared, displaying the same symbol as above: <1><74>: Abbrev Number: 2 (DW_TAG_subprogram) <1><2eb86>: Abbrev Number: 19 (DW_TAG_pointer_type) |
FYI... even if I do this, the debug symbols are not in the hello executable: go build -linkshared -gcflags '-dwarf' hello.go |
Yes to the latter. http://www.dwarfstd.org/doc/DWARF4.pdf#page=163 is the relevant part of the DWARF4 spec. AIUI you just emit a relocation to a named symbol, same as if you were calling a function, and then the debugger is responsible for resolving that relocation when it reads the debug information. My guess at the implementation in the Go linker would be:
None of this explains why libstd doesn't reference its own types, of course. Maybe we should open a separate bug to investigate adding the debug sections to shared mode executables? As you say, there really isn't much point in worrying about this until that's done. |
Oh I see now that -w (disable dwarf) is passed into the linker when -linkshared is used. This code in
|
That's good to know. For some reason, I've never gotten to the point of absorbing a good mental model of how DWARF works...
+1
FWIW, this is new-ish, libstd.so used (i.e. 1.7, probably) to have semi-reasonable debug data.
I think this would make sense yes. (I've debugged shared libraries a whole bunch with gdb of course, but I guess like Lynn, it's mostly been in the "single stepping assembly" sort of fashion) |
I tried out a go 1.7 toolchain and verified that the problem with the missing DIE in libstd.so does not happen there. It does happen in 1.8 and master. |
I'm also hitting this issue on AArch64 with go1.9 and master(on Fedora 28/27). Actually I'm debugging other issue that is arising with shared bins on arm64, some seg faulting(issue pending). It is unfortunate that this breaks gdb, it hangs on I have bit played with the dwarf_test in the cmd/link and it will detect this issue when executed with shared flags. IMHO it would be good to enable it in long term(when dwarf generation is fixed/disable for dynamic libs). Is there any progress on this issue? Is there way i can help? |
No progress that I'm aware of, and it's too late for 1.10 at this point. Note that if you just don't want gdb to freeze, @laboger said running the strip command on libstd.so was enough to fix that. |
I found this regression was introduced by this commit:
|
This error no longer occurs on ppc64le on latest. If someone can verify if it works for arm64 it can be closed. |
Really? I can't seem to cross-compile a shared library for ppc64le, but at least in amd64, there's still no DWARF in a -linkshared hello world binary. If it's fixed I would be curious to know what fixed it. |
In my previous post I meant that I no longer see the error message and failure from gdb when trying to debug a program built with -linkshared on latest. The dwarf is still not being generated in the main program when built with -linkshared and I see no way to do that, so that part has not been fixed. |
Obsoleted by #47788 |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go tip
What operating system and processor architecture are you using (
go env
)?Ubuntu 16.04 ppc64le
What did you do?
go install -buildmode=shared std
go build -linkshared hello.go
gdb ./hello
break main
run
What did you expect to see?
Normal debugging with gdb as with other Go programs.
What did you see instead?
Errors from gdb and unable to debug the program at all. The following error message prevented break points from being set.
....
Error in re-setting breakpoint 1: Dwarf Error: Cannot find DIE at 0x0 referenced from DIE at 0xc8 [in module /home/boger/golang/base/go/pkg/linux_ppc64le_dynlink/libstd.so]
The text was updated successfully, but these errors were encountered: