Skip to content

Fix ConstructorInvoker.Create with a null argument - #138309

Merged
MichalStrehovsky merged 1 commit into
dotnet:mainfrom
aaronfranke:fix-1.8-cons-inv-create-null-arg
Nov 26, 2026
Merged

MichalStrehovsky merged 1 commit into
dotnet:mainfrom
aaronfranke:fix-1.8-cons-inv-create-null-arg

Conversation

@aaronfranke

Copy link
Copy Markdown
Contributor

This factory function needs a non-null argument, but did not guard against it at the start of the function. This causes problems when using native AOT (I'm not entirely sure what, but the fix is pretty simple).

Minimal reproduction project: nativeaot-constructorinvoker-null.zip


AI usage disclaimer: I encountered these .NET runtime bugs when using an AI to work on an unrelated project. I had it fix the bugs as it went, and now I am submitting fixes to each after manually reviewing the changes, and fixing them as needed. Most of these lines of code are AI-generated, including the tests and the MRP. The PR description and commit message are entirely human-written, as is always the case with every PR I open.

This factory function needs a non-null argument,
but did not guard against it at the start of the function.
This causes problems when using AOT.
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 25, 2026
@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: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

@MichalStrehovsky MichalStrehovsky 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.

This causes problems when using native AOT (I'm not entirely sure what, but the fix is pretty simple).

The only problem is that it will throw ArgumentException 5 lines below instead of ArgumentNullException. Surprised any code would even rely on that.

@MichalStrehovsky

Copy link
Copy Markdown
Member

/ba-g some networking test failure

@MichalStrehovsky
MichalStrehovsky merged commit 328c39f into dotnet:main Nov 26, 2026
114 of 116 checks passed
@aaronfranke
aaronfranke deleted the fix-1.8-cons-inv-create-null-arg branch November 26, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants