-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: darwin_amd64: running dsymutil failed: signal: segmentation fault #23374
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
Comments
/cc @thanm |
I will take a look. What flavor of IOS and/or Xcode are you using? |
Thank you much!
That's Low Sierra and, I believe, XCode 9.2, but I don't know how to tell for sure given that I've only got the command line tools installed. |
I have been able to reproduce the problem (took a while to get things set up). Working on finding the root cause now. |
Inline in question is taking place within github.com/cockroachdb/cockroach/pkg/storage/engine/enginepb.(*MVCCMetadata).Size, at call to github.com/cockroachdb/cockroach/pkg/storage/engine/enginepb.(*MVCCStats).Size. Here is the bad inline info DIE:
The abstract origin for the second formal is off by 1 -- it is 0x83512d, should be 0x83512c. Not sure why... time to dig some more. |
I think I finally have a handle on what's happening here. This was a very difficult bug to track down. The problem seems to be that there are different versions of the abstract subprogram DIE being generated depending on whether we're compiling the package P containing an inlinable function F, vs. compiling some other package that imports P and uses F. Here is the abbreviation entry description for an abstract parameter:
Note the decl_line DIE -- it uses variable-length encoding, meaning the larger the line number, the more bytes consumed. Here is the inlinable function of interst:
When the package containing this function is compiled, the compile captures the declaration line of all interestin variables, meaning line 553 for 'm' and 'n' and 554 for 'l'. It emits an abstract function DIE with abstract param/local child DIEs based on this info. The build continues for a while, then some other package that imports 'enginepb' and uses the method above. In this version of the compile, somehow the declaration line values for 'l' and 'n' are correct, but the line for 'm' is being set not to the correct line number but to the line number of the 'import' statement that pulls in enginepb (something about the fact that it is the receiver?). Ordinarily nobody would care (hardly anyone looks at this sort of debug info) but in this case when the line number is LEB-encoded as the DIE is emitted, the block only takes one byte instead of the 2 bytes it takes to emit the correct line of 553. This means that the offset of the next abstract parameter DIE ('n') in this case is computed differently (instead of the offset of 101 in the home package), we get an offset of 100, or vice versa. Possible solutions:
Longer term we could track down the reason for the declaration line inconsistency, but it's not clear that there is an easy fix for that (since presumably it would mean making sure that it got written to the export data for the function). |
I chatted with Austin for a bit this afternoon about possible solutions. For the short term I think it makes sense to pick option 2 (removing decl_line from abstract param abbrev entry). |
Change https://golang.org/cl/87055 mentions this issue: |
Given an inlinable method M in package P: func (r *MyStruct) M(...) { When M is compiled within its home package, the source position that the compiler records for 'r' (receiver parameter variable) is accurate, whereas if M is built as part of the compilation of some other package (body read from export data), the declaration line assigned to 'r' will be the line number of the 'import' directive, not the source line from M's source file. This inconsistency can cause differences in the size of abstract parameter DIEs (due to variable-length encoding), which can then in turn result in bad abstract origin offsets, which in turn triggers build failures on iOS (dsymutil crashes when it encounters an incorrect abstract origin reference). Work around the problem by removing the "declaration line number" attribute within the abstract parameter abbreviation table entry. The decl line attribute doesn't contribute a whole lot to the debugging experience, and it gets rid of the inconsistencies that trigger the dsymutil crashes. Updates #23374. Change-Id: I0fdc8e19a48db0ccd938ceadf85103936f89ce9f Reviewed-on: https://go-review.googlesource.com/87055 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
Thanks for the patch. Am I correct in thinking that this is now as fixed as it is going to be for 1.10, and so the issue should be moved to 1.11? |
Correct. I want to understand why the srcpos for the receiver variable is different in the two scenarios -- ideally it would be identical in both cases (compiling local inlineable routine vs compiling imported inlinable routine). |
Thanks for the fast turnaround, @thanm! That doesn't sound like it was fun. |
Closing this out, has been fixed for a while. |
I just subscribed to this a couple of days ago because I'm sill getting it after upgrading to 1.10.1. What was/is the fix? |
Are you sure it's the same issue, @jrwren? Are you seeing the segfault when compiling Cockroach or another piece of software? |
I definite get
I think it is followed by I'm compiling our internal software. It does not include Cockroach. |
"running dsymutil failed" means that the Go toolchain produced a binary that was rejected by macOS's toolchain. There are myriad reasons this could happen—basically any misplaced bit during linking could cause this—and it's statistically unlikely that it happens to be the same problem that was addressed here. I think you're best off filing another issue with a code sample that reproduces the issue! |
Agree with @benesch -- there are many reasons why dsymutil can have problems. Please file an issue if possible. |
Just to get this out of the way: a very similar issue was described in #23046, but I'm running a version of Go that includes the fix to that issue.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No.
What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
A built
cockroach
binary.What did you see instead?
A few thoughts, in no particular order:
make build
in the Cockroach repository once to compile a few C/C++ dependencies. We generate Go files with the appropriate cgo flags so that, after the firstmake build
, a barego build
will work correctly (until the C/C++ dependencies need to be recompiled, of course).go build -ldflags=s
andgo build -ldflags=-w
both produce working binaries, which suggests the problem is DWARF-related, as in cmd/go: running dsymutil failed: signal: segmentation fault #23046.The text was updated successfully, but these errors were encountered: