You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: (bug) int.Log2/long.Log2 with a negative constant corrupts the importer stack (InvalidProgramException) #133711
Expected:System.ArgumentOutOfRangeException from int.Log2 (it throws for negative input). Actual:Unhandled exception. System.InvalidProgramException: Common Language Runtime detected an invalid program. (exit code 0xE0434352)
Notes:
csc -optimize+, then corerun repro.dll. Reproduces with tiering on, with DOTNET_TieredCompilation=0, and with -optimize-.
long.Log2(-1L) fails the same way; so does a call with another value underneath on the stack, e.g. k + int.Log2(-1).
src/coreclr/jit/importercalls.cpp:6935-6959 (NI_PRIMITIVE_Log2): the constant branch calls impPopStack() before checking signedness, and for a negative signed constant leaves result == nullptr, so the intrinsic is declined after the argument has already been removed from the importer stack.
Activity
dotnet-policy-service commentedon Sep 11, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: preserve importer stack for negative constant Log2 (#133725)
JIT: preserve importer stack for negative constant Log2 (dotnet#133725)
EgorBo commentedon Sep 18, 2026
Affected SDK versions: