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
runtime: Windows: pprof output is broken in cgo packages for go test -cpuprofile #18416
Comments
On the old issue, rsc wrote:
Now you write:
But there's no mention of go1.8 in this bug report(?). You only show results from 1.6 and 1.7. Did you try tip (the current master, soon-to-be go1.8)? Can you reproduce this on tip? |
I made sure to remove the existing binary and profile.
|
I copied the "bug" versions of your file but changed the package to issue18416.
With current tip:
I am not seeing the result you report, where you get no results. However, I am running on GNU/Linux, so this may be somehow Windows-specific. |
I very much so have this feeling as well. |
git-bisect result:
|
I can reproduce this too. Only on windows/386, and, yes, it is broken by ed8f0e5. I have built issue18416.test.exe with
that all PE symbols in bad.exe have superfluous underscore in front of them. So cmd/internal/objfile won't find any symbols in that executable. All correspondent go tools (nm, objdump, maybe others) would be broken too. This is for cgo only. We have a test for this in cmd/nm, but it does not test cgo. I will let others decide what to do here. Please, let me know if I can help in any way. Thank you. Alex |
The underscores are necessary on that version of Windows. That's why they are there. They are not superfluous. We have had this discussion before. |
Why are they necessary?
Perhaps. I am an old man. I forget things. Do you plan to fix broken pprof tool? And nm and objdump? Thank you. Alex |
The mangling scheme was established by Microsoft, and has been informally followed by other compilers including Digital Mars, Borland, and GNU GCC, when compiling code for the Windows platforms. The scheme even applies to other languages, such as Pascal, D, Delphi, Fortran, and C#. This allows subroutines written in those languages to call, or be called by, existing Windows libraries using a calling convention different from their default. When compiling the following C examples:
32 bit compilers emit, respectively:
In the stdcall and fastcall mangling schemes, the function is encoded as _name@X and @name@X respectively, where X is the number of bytes, in decimal, of the argument(s) in the parameter list (including those passed in registers, for fastcall). In the case of cdecl, the function name is merely prefixed by an underscore. The 64-bit convention on Windows (Microsoft C) has no leading underscore. I do not plan on fixing the broken tools, since that is the responsibility of the people that made them. I don't like the convention Microsoft established, but that is nonetheless what they did. |
@nadiasvertex thanks for explaining. I will try fix this issue myself. Alex |
CL https://golang.org/cl/35076 mentions this issue. |
@smithjacobj could you try this change https://go-review.googlesource.com/#/c/35076/ to see if it fixes your problem. Thank you. Alex |
@alexbrainman apologies for the delay, I didn't noticed the mention. I have tested with the patch and it appears to resolve the issue. |
Thank you for confirming. Alex |
Old issue: #16891
I'm concerned that even with embedded symbols in 1.8, this will still be an issue.
Please answer these questions before submitting your issue. Thanks!
go version
)?1.7 windows/386
go env
)?Windows, 386
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
run
go test
on a package with the-cpuprofile
flag.Using output from 1.6.3, I get the following result from
pprof top10
:Using output from 1.7, I get the following result from
pprof top10
The issue seems to be related to use of the
github.com/google/gopacket/pcap
package, which binds tolibpcap
via CGoI tested with a bare CGo sample, and also a control.
Control results:
Bug results:
Control:
impl
test
Bug
impl
test
The text was updated successfully, but these errors were encountered: