skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.67k stars 185 forks source link

Issues with `ld` crashing #54

Open luc0x61 opened 1 year ago

luc0x61 commented 1 year ago

I've had issues with ld crashing on invocation, which I resolved using a linker from another MinGW binary distribution. Unfortunately, I can't share the setup or the files involved, then I understand how vague is all this, even though I started a tentative explanatory question on StackOverflow.

I replicated the problem in a couple of environments. It appeared/disappeared even after changing a few instructions in the sources. Something suggests an issue with the kind of initialization of the memory, as at a certain point I had also different results in different command processors (cmd.exe, TCCle).

Peter0x44 commented 1 year ago

Can you at least share the version of binutils the other working binary distribution was using?

skeeto commented 1 year ago

Looks like I hadn't noticed a Binutils release earlier this year, so I've updated that to Binutils 2.40 in 7f6e0ba. The release notes indicate it contains "numerous bug fixes" which perhaps includes your issue. If you're able to build w64devkit yourself — requires only Docker or Podman — give that a shot. Since you're using the i686 variant, use my script:

./multibuild.sh -q4

This works with Docker Desktop on Windows, and you can run the build shell script using w64devkit itself. That will produce a w64devkit-i686.zip for you to try. Alternately you could provide a minimal example so that I could test it. I was unable to produce the crash using --image-base.

It's now possible to build Binutils using w64devkit (see #50), so another approach is to compile a Binutils debug build, then point w64devkit's GDB at it to examine the issue in a live processes with debug symbols. If I could reproduce the bug I'd try this myself.

I don't anything particularly special building Bintils aside from:

These seem unlikely to affect your issue, especially since you're using "-static" explicitly, so I suspect the other ld also has the bug but just so happens to be built in such a way it doesn't crash.

luc0x61 commented 1 year ago

@skeeto thank you for answering my murky issue, I know it gives as much information as a "don't work" alone. It's hard to reproduce even with this project I'm compiling. Now I'm building it with a linker version 2.30, with which it hasn't crashed (yet?).

I will consider the rebuild as you tell me, but I'm not supported too much in the investigation, and I'm encouraged to keep going with the original task and be on time.

luc0x61 commented 1 year ago

Just to reassure you: I quickly tested an ld version 2.40 from here and the problem is still there. My only chance to be helpful is then to have a shareable test suit and submit it to binutils developers, but this is still a complex task for now 🤷