google / wuffs

Wrangling Untrusted File Formats Safely
Other
4.14k stars 127 forks source link

MSVC internal compiler error #151

Open tksuoran opened 1 month ago

tksuoran commented 1 month ago

FYI: https://developercommunity.visualstudio.com/t/fatal--error-C1001:-Internal-compiler-er/10703305

I have not tried to make a minimal repro yet, but at least the workaround might be useful while waiting for MS to fix the compiler not to crash.

nigeltao commented 1 month ago

Thanks for the FYI.

Another workaround might be to temporarily downgrade wuffs-v0.4.c from the latest (alpha) version, v0.4.0-alpha.5, to the previous one (v0.4.0-alpha.4: check out commit https://github.com/google/wuffs/commit/f1698226806569eb45ea009deee89a108f8d5395) until we hear more from the Microsoft C++ team.

nigeltao commented 1 month ago

I don't use Windows or MSVC, so I'm only guessing, but I'm curious if your "Internal compiler error" repro still crashes (with the latest Wuffs version, v0.4.0-alpha.5) if you pass the /arch:AVX or /arch:AVX2 compiler flag.

tksuoran commented 1 month ago

I am already using the v0.4.0-alpha.5 tag. I added /arch:AVX2 - the ICE still happens the same.

tksuoran commented 1 month ago

This config does not trigger MSVC ICE:

#define WUFFS_CONFIG__MODULES
#define WUFFS_CONFIG__MODULE__ADLER32
#define WUFFS_CONFIG__MODULE__AUX__BASE
#define WUFFS_CONFIG__MODULE__AUX__IMAGE
#define WUFFS_CONFIG__MODULE__BASE
#define WUFFS_CONFIG__MODULE__JPEG

If I add CRC32 module (required by PNG), there ICE gets triggered.

#define WUFFS_CONFIG__MODULES
#define WUFFS_CONFIG__MODULE__ADLER32
#define WUFFS_CONFIG__MODULE__AUX__BASE
#define WUFFS_CONFIG__MODULE__AUX__IMAGE
#define WUFFS_CONFIG__MODULE__BASE
#define WUFFS_CONFIG__MODULE__CRC32
#define WUFFS_CONFIG__MODULE__JPEG
nigeltao commented 1 month ago

Huh, interesting.

I still don't have MSVC but if you have the time, you could #define WUFFS_CONFIG__MODULE__CRC32 (to trigger ICE) and then delete lines of code from the wuffs_crc32__ieee_hasher__up_x86_sse42 function (in wuffs-v0.4.c line 36762) until the ICE stops? That might give us (and the Microsoft C++ team) a reproducer.

If you want a minimal reproducer, you should be able to trim the module allow-list to just this:

#define WUFFS_CONFIG__MODULES
#define WUFFS_CONFIG__MODULE__CRC32
nigeltao commented 1 month ago

I've just rolled Wuffs v0.4.0-alpha.6, which rolls back to the v0.4.0-alpha.4 behavior where, on MSVC, SIMD is opt in (instead of v0.4.0-alpha.5's opt out).

You can still get ICE if you opt in, but at least you should no longer see this ICE by default.

#define WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2 (or _V3) to opt in.