-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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/compile: sanity check in makePreinlineDclMap can fail #38698
Comments
Yes, this is a drawback of the current implementation -- it assumes that variables and parameters have unit source positions. |
This shrinks binaries by about 6%, if you're using -ldflags=-w. Backtraces should still work, with function names and PCs and arguments, but all line numbers will display as x.go:1. This breaks any tests that depend on correct line numbers. For example, net/http: --- FAIL: TestWriteHeaderNoCodeCheck_h1hijack (0.00s) x.go:1: stderr output = "http: response.WriteHeader on hijacked connection from net/http_test.testWriteHeaderAfterWrite.func1 (x.go:1)"; want "http: response.WriteHeader on hijacked connection from net/http_test.testWriteHeaderAfterWrite.func1 (clientserver_test.go:" --- FAIL: TestWriteHeaderNoCodeCheck_h1 (0.01s) x.go:1: stderr output = "http: superfluous response.WriteHeader call from net/http_test.testWriteHeaderAfterWrite.func1 (x.go:1)"; want "http: superfluous response.WriteHeader call from net/http_test.testWriteHeaderAfterWrite.func1 (clientserver_test.go:" FAIL FAIL net/http 13.940s Remove an invariant check in dwinl.go that's broken by this. See golang#38698. That may break debugging. But if you care enough about binary size to use this, you're already stripping binaries with -ldflags=-w. Remove a security check around cgo pragma placements. Unfortunate, but if you're using a hacked toolchain, you should always make sure your code still builds and passes tests with a regular toolchain. Change-Id: I56c7540ea856a3bdccf8d44b5c3dbd4803545015
@thanm does https://golang.org/cl/294289 by chance fix this issue as well? |
(If so, it’d still be good to add it as an additional test.) |
Yes, the change from https://golang.org/cl/294289 does indeed fix this issue. Thanks for spotting that. |
Change https://golang.org/cl/295129 mentions this issue: |
This code is obviously contrived/ridiculous, but the point remains--in the presence of line directives, we cannot safely assume that the contents of any given source positions are unique.
cc @thanm
The text was updated successfully, but these errors were encountered: