Repository navigation
Description
Description
A Fuzzlyn-generated program throws System.InvalidProgramException: Common Language Runtime detected an invalid program when compiled and run in Debug configuration. The same program runs without errors in Release configuration.
ILVerify reports the IL as valid (All Classes and Methods Verified), suggesting the JIT incorrectly rejects legal IL in unoptimized (MinOpts/Debug) mode.
Reproduction Steps
The program was found by Fuzzlyn with seed:
4401835540114508456-vectort,vector128,vector256,vector512,x86aes,x86avx,x86avx2,x86avx512bw,x86avx512bwvl,x86avx512cd,x86avx512cdvl,x86avx512dq,x86avx512dqvl,x86avx512f,x86avx512fvl,x86avx512fx64,x86avx512vbmi,x86avx512vbmivl,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86gfni,x86gfniv256,x86gfniv512,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86pclmulqdqv256,x86pclmulqdqv512,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base
The code is a massive 2k lines (Program-full.cs) line program that uses intrinsic. Fuzzlyn reducer was taking too much time to reduce so I tried to do a partial cleanup by hand (Program-reduced.cs). Reduced to ~200 lines that still throws InvalidProgramException in Debug.
So both (full repro and the reduced one) when run in debug mode
dotnet run -c Debug
produces the same unhandled exception
Unhandled exception. System.InvalidProgramException: Common Language Runtime detected an invalid program.
at Program.M0()
at Program.Main() in Program.cs:line XXX
There's slightly different output in release
dotnet run -c Release
The full repro produces no exception, runs to completion (no output expected - the program has no Console.WriteLine). The reduced on throws IndexOutOfRangeException exception (I was probably cleaned too much by focusing on having InvalidProgramException in Debug; didn't check the Release mode).
Expected behavior
The program should behave identically in Debug and Release configurations. ILVerify confirms the IL is valid, so the JIT should not reject it.
Actual behavior
Debug: throws InvalidProgramException during JIT compilation of method M0().
Release: runs without error. (full repro)/ IndexOutOfRangeException (reduced repro)
Regression?
Unknown. Not tested on versions prior to .NET 10.
Known Workarounds
No known workarounds
Configuration
.NET SDK: 10.0.201
Runtime: Microsoft.NETCore.App 10.0.5
OS: Windows 11 x64 (Build 26200)
Architecture: x64
CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80 GHz
The bug is CPU-dependent. It reproduces only on CPUs with extended AVX-512 extensions (e.g. VBMI, GFNI, VPCLMULQDQ), not on CPUs with basic AVX-512 only (F, BW, DQ, CD, VL).
CPU where bug reproduces (extended AVX-512):
avx512f avx512dq avx512cd avx512bw avx512vl avx512ifma avx512vbmi avx512_vbmi2 avx512_vnni avx512_bitalg avx512_vpopcntdq avx512_vp2intersect gfni vaes vpclmulqdq sha_ni
CPU where bug does NOT reproduce (basic AVX-512 only):
avx512f avx512dq avx512cd avx512bw avx512vl
Extensions present only on the affected CPU:
avx512ifma, avx512vbmi, avx512_vbmi2, avx512_vnni, avx512_bitalg, avx512_vpopcntdq, avx512_vp2intersect, gfni, vaes, vpclmulqdq, sha_ni
Several of these match extensions enabled in the Fuzzlyn seed (x86avx512vbmi, x86avx512vbmivl, x86gfni, x86gfniv256, x86gfniv512, x86pclmulqdq, x86pclmulqdqv256, x86pclmulqdqv512), suggesting the JIT codegen path for one of these extensions triggers the bug.
Other information
I've also run the fully generated code sample on a docker with dotnet/nightly/sdk:11.0-preview with the same effect (Debug - InvalidProgramExchaption).
Attached:
- Full generated program (~2k lines, reproduces exactly: Debug throws InvalidProgramException, Release runs clean)
- Partially reduced program (~200 lines, Debug still throws InvalidProgramException, but Release behavior differs from original due to reduction)
Activity
dotnet-policy-service commentedon Apr 6, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
tannergooding commentedon Apr 6, 2026
I'd just note that calling it 200 lines is a bit of a misnomer, IMO. There are a few lines that are themselves several hundred nested expressions (and with wordwrap turn into a hundred lines themselves).
Going to take a look at this and see if I can simplify it more or find out what's faulting
tannergooding commentedon Apr 6, 2026
Looks like an emit failure in
M0. Specifically the following stacktrace where we hit an impl limitation:pawlos commentedon Apr 7, 2026
Ok. The lines are indeed quite long. But I was hoping the 200 of those would be more manageable than 2k.
EgorBo commentedon Apr 7, 2026
Marking as Future - the repro is not realistic (>32k locals) + it doesn't lead to an undefined behavior/memory safety issue, just a well-defined InvalidProgramException. The fix seems to be straightforward, but we might have more places like that.
Reject folding local addresses the emitter cannot encode (#130990)