Skip to content

ReadyToRun images crash if compiled for AVX2 but run on non-AVX2 CPU #61471

@rickbrew

Description

@rickbrew

Update: Crash also happens if R2R image is built for SSE4.2 and run on CPU that only supports SSSE3 (I added a reply below)

Description

I'm using crossgen2 and .NET 6.0.0 GA with the following options to build a composite R2R image for my app (Paint.NET),

--targetos:windows --targetarch:x64 --optimize-time --composite --inputbubble --compilebubblegenerics --instruction-set:avx2,bmi,bmi2,lzcnt,popcnt,fma

From what I'm told, this image should still run fine on systems without support for these instruction sets, but the precompiled code will be ignored in favor of JITting. (or at least, any precompiled code which uses those instructions will be discarded -- still haven't heard conclusively if it's selective exclusion or if the whole native image is ignored)

However, I received a report from a private tester that the app just crashes. Their CPU is a Pentium(R) Dual-Core CPU T4400 which supports up through SSSE3.

If I use bcdedit /set xsavedisable 1 on my own system, which is a Ryzen 5000 series CPU, I'm also able to reproduce the crash.

So it looks like ReadyToRun is doing something wrong here.

cc @tannergooding @EgorBo @AndyAyersMS

Reproduction Steps

Compile an app using crossgen2 and --targetos:windows --targetarch:x64 --optimize-time --composite --inputbubble --compilebubblegenerics --instruction-set:avx2,bmi,bmi2,lzcnt,popcnt,fma

Run the app on an older CPU that lacks AVX2, or run bcdedit /set xsavedisable 1 and reboot and run it on a CPU that is more recent.

Expected behavior

Everything works fine

Actual behavior

Crashes. Event Viewer has an entry for the app showing that it crashed.

Regression?

Not sure if this is a regression.

Known Workarounds

Compile with --instruction-set:sse2 instead.

Configuration

.NET 6.0.0
Windows 10/11
x64
CPU that lacks AVX2, or on one that does have AVX2 but first run bcdedit /set xsavedisable 1 and reboot

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions