Open anacrolix opened 5 days ago
I reported this downstream https://github.com/google/go-cmp/issues/359, but I believe the issue is in go.
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
None of the related issues match this problem.
Hi @anacrolix I am having trouble reproducing this problem -- when I build + run your test case on our windows/arm64
builders, it seems to work just fine. I tried both with tip of master and with Go 1.22.4.
Your go env
output shows a Darwin machine, just confirming that this is indeed a windows issue and not a Darwin issue? Might help if you could tell me a bit more about the setup/configuration of the windows machine where you're seeing the problem. Thanks.
Thanks for looking. Specifically I cross compiled from darwin to windows/amd64, then ran that binary on Windows 11 on windows/arm64.
Still can't reproduce. From my darwin arm64 machine I built the program you listed via
GOOS=windows GOARCH=amd64 go build prog.go
downloaded the resulting executable to a windows/arm64
builder, still works fine. What am I missing?
I couldn't reproduce as well. This feels like the error you would get by copying the regexp from the internet and some character in the regexp string would have a different encoding. But given this happens with a library upstream I'd say it is probably something to do with the OS.
Could it be CGO related? I am linking in a bunch of other stuff, and using a cross compiler (x86_64-unknown-linux-gnu-gcc) for some of those cgo parts.
At a stretch, could it be triggered by some kind of memory or emultation corruption? Are your windows/arm64 instances emulated (mine is).
The (downstream) library you mention is heavily used, AFAICT the character classes it's using are well defined too.
Let me know what else I can provide? Thanks
CGO: sure, I can certainly imagine problems there, but it depends on the code of course.
Are your windows/arm64 instances emulated (mine is).
The Go team windows/arm64 builders are Azure VMs, and I am pretty sure they are backed by actual arm hardware.
I'll try to construct a minimal reproduction. Thanks for looking into it
I'm only able to reproduce with upx involved. I've mentioned an issue in upx that looks related. Obviously this could be out of the scope of Go, however I'm able to reproduce it from a part of my code that additionally seems to incorrectly depend on go-cmp
.
I've created a repo to reproduce at https://github.com/anacrolix/go-issue-68268. It contains some code guarded by conditions, and additionally that can be commented out to avoid compiling in the dependencies. The behaviour varies significantly if you mess around with it. The justfile contains some build steps, and copies to my Windows ARM VM.
If I use my package github.com/anacrolix/torrent/bencode
, a dependency is generated to github.com/google/go-cmp/cmp
via github.com/anacrolix/torrent/bencode.test
(Comment out all the other lines to see this behaviour). When the resulting binary is run through upx, something must be stripped out. It's not clear why this code is included in the first place however.
> go mod why -m github.com/google/go-cmp
# github.com/google/go-cmp
github.com/anacrolix/go-issue-68268
github.com/anacrolix/torrent/bencode
github.com/anacrolix/torrent/bencode.test
github.com/google/go-cmp/cmp
CGO is not related at all. I don't have real ARM hardware running Windows, but I also think that's not the problem either.
@anacrolix The best way to help make progress on the upx side is to "Paste, drop, or click to add files" (or give the URL) of an actual (never compressed yet) executable file which runs, but which fails when compressed by upx. (ref: https://github.com/upx/upx/issues/443) So far I cannot find such a file here.
@jreiser I thought it would be preferable to build it yourself from source (per the repo). Here's the exe that runs fine before upx. fine-before-upx.zip
@anacrolix Thank you for the file. An actual executable file is a cut point in the graph of debugging possibilities, so it is the first place to look. Repo, integrated development environment (options, menu settings, environment variables, compiler/linker, Python site packages integrations, etc.), and system or local static libraries often introduce dozens of variables. Variations in the OS (Windows 11, latest 10, early 10, 7) sometimes present their own problems, but having a specific actual executable file still helps.
Go version
master and 1.22 (and probably other versions)
Output of
go env
in your module/workspace:What did you do?
I'm using github.com/google/go-cmp on Windows ARM. It was compiled for amd64. This is a playground for it, but obviously it's not cross compiled: https://go.dev/play/p/8a4Kt1DD-al?v=gotip.
What did you see happen?
A panic during init. The init code looks fine. The binary also appears to be loading fine, it just doesn't like this character class.
What did you expect to see?
go-cmp's init to work normally and main to start.