-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release/9.0] Fix invalid handle bug happening when TypeBuilder
type used in exception catch clause
#106704
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-reflection-emit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI some unrelated errors in Build Analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this is green, it's approved for merge into RC2 as it's a bug in a new feature in .NET 9.
/ba-g no failure related to PR or unknown FYI: @carlossanlop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
M2 approved
Backport of #106665 to release/9.0
/cc @buyaa-n
Customer Impact
This is found while reviewing
PersistedAssemblyBuilder
implementation entirely. When newly createdTypeBuilder
instance is used as exception type, whenILGenerator.BeginCatchBlock(Type? exceptionType)
calledILGenerator
will throw because theTypeBuilder
token is invalid, it works fine when existing exception types used.Root cause:
A newly created
TypeBuilder
token is not valid whenILGenerator.BeginCatchBlock(Type? exceptionType)
called and the token will not be populated properly until the assembly saved into a file or stream.Solution
Instead of adding exception handler blocks directly into the
ControlFlowBuilder
instance, now collecting them into a list and adding them to theControlFlowBuilder
during Save where all tokens will have populated properly.Regression
It is a bug in a new PersistedAssemblyBuilder added in .NET 9
Testing
A unit test added that reproes the issue
Risk
Low, the fix is straight forward and clean, should not cause a regression
Side note
No new API added with the PR, instead if removed an overriden API from ref that is not needed to be overriden