Skip to content

[Breaking change]: System.InvalidProgramException thrown when stack parameter type is incompliant to the parameter type in method signature as per ECMA-335  #26346

Closed
@kunalspathak

Description

@kunalspathak

Description

Earlier, on x86, .NET would tolerate an incorrect IL and would lead to incorrect execution. The change in dotnet/runtime#43386 fix it by rejecting such incorrect IL by throwing System.InvalidProgramExecution exception.

Version

.NET 6 preview 1

Version

Other (please put exact version in description textbox)

Previous behavior

See dotnet/runtime#43342 for more details.

New behavior

In new behavior, if incompliant IL is seen, JIT will reject it and runtime would throw Unhandled exception. System.InvalidProgramException: Common Language Runtime detected an invalid program. exception.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.

Reason for change

The old behavior was incompliant with ECMA-335, page 305, Table III.9 "Signature Matching" and JIT would accept incorrect IL leading to incorrect execution.

Recommended action

On x86, user need to make sure that the parameter type matches to that on stack. See an example of the action taken to fix the IL. dotnet/runtime#45453

Feature area

JIT

Affected APIs

No response

Metadata

Metadata

Assignees

Labels

binary incompatibleExisting binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions