Skip to content

Preserve last error when compiling method called from interpreter - #137418

Merged
BrzVlad merged 1 commit into
dotnet:mainfrom
BrzVlad:fix-clrinterp-lasterror
Nov 12, 2026
Merged

BrzVlad merged 1 commit into
dotnet:mainfrom
BrzVlad:fix-clrinterp-lasterror

Conversation

@BrzVlad

@BrzVlad BrzVlad commented Nov 12, 2026

Copy link
Copy Markdown
Member

When a method is called for the first time, from compiled code, it goes through ThePrestub. In PreStubWorker we save the last error information, so that method compilation doesn't dirty it. Calls from the interpreter are not going through ThePreStub, calling DoPrestub directly. This code path was missing the saving/restoration of the last error.

This fixes an issue where Environment.GetEnvironmentVariableCore would fail to differentiate between missing and empty string env var, when this path is first compiled. (see Environment.Variables.Windows.cs which, despite the name, is used on all platforms with CoreCLR). Should fix coldsignaturedispatch failure on interp pipelines, which got incorrect values for GetEnvironmentVariable("DOTNET_GCStress") != null.

When a method is called for the first time, from compiled code, it goes through ThePrestub. In PreStubWorker we save the last error information, so that method compilation doesn't dirty it. Calls from the interpreter are not going through ThePreStub, calling DoPrestub directly. This code path was missing the saving/restoration of the last error.

This fixes an issue where `Environment.GetEnvironmentVariableCore` would fail to differentiate between missing and empty string env var, when this path is first compiled. (see `Environment.Variables.Windows.cs` which, despite the name, is used on all platforms with CoreCLR). Should fix `coldsignaturedispatch` failure on interp pipelines, which got incorrect values for `GetEnvironmentVariable("DOTNET_GCStress") != null`.
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli
See info in area-owners.md if you want to be subscribed.

@janvorli janvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@BrzVlad
BrzVlad merged commit 7bbc575 into dotnet:main Nov 12, 2026
115 of 117 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants