-
Notifications
You must be signed in to change notification settings - Fork 128
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
Fix broken try/catch/filter offsets after isinst optimization #2205
Conversation
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.
LGTM!
The isinst optimization replaces that instruction with a pop, ldnull when the type is not instantiated. This changes the instruction and also changes the length of the instruction in that position. Cecil unfortunately doesn't update try/catch/filter references and they keep pointing to the old isinst instruction which not part of the method body anymore. When saving the assembly the offsets stores in the try/catch/filter records end up effective random and corrupted. This is a short-term fix to unblock failures in runtime due to this problem. Medium term fix would be to carefully handle all IL replacements in the linker with regard to try/catch/filter records. Ideally the long term fix would be to do this in Cecil in such a way that IL replacements would be correctly handled on their own. This fixes the Http3RequestStream failures mentioned in #2181, but I was not able to confirm if this fixes the CoreLib ArrayPool issues as well (I think it will not). |
Part of the linker issue dotnet/linker#2181 has been fixed in dotnet/linker#2205. This part was the one affecting Http3RequestStream. This change simple reverts the workaround since it's not needed anymore.
Part of the linker issue dotnet/linker#2181 has been fixed in dotnet/linker#2205. This part was the one affecting Http3RequestStream. This change simple reverts the workaround since it's not needed anymore.
…/linker#2205) The isinst optimization replaces that instruction with a pop, ldnull when the type is not instantiated. This changes the instruction and also changes the length of the instruction in that position. Cecil unfortunately doesn't update try/catch/filter references and they keep pointing to the old isinst instruction which not part of the method body anymore. When saving the assembly the offsets stores in the try/catch/filter records end up effective random and corrupted. This is a short-term fix to unblock failures in runtime due to this problem. Medium term fix would be to carefully handle all IL replacements in the linker with regard to try/catch/filter records. Ideally the long term fix would be to do this in Cecil in such a way that IL replacements would be correctly handled on their own. This fixes the Http3RequestStream failures mentioned in dotnet/linker#2181, but I was not able to confirm if this fixes the CoreLib ArrayPool issues as well (I think it will not). Commit migrated from dotnet/linker@4dd506a
The isinst optimization replaces that instruction with a
pop, ldnull
when the type is not instantiated. This changes the instruction and also changes the length of the instruction in that position. Cecil unfortunately doesn't update try/catch/filter references and they keep pointing to the oldisinst
instruction which not part of the method body anymore. When saving the assembly the offsets stores in the try/catch/filter records end up effective random and corrupted.This is a short-term fix to unblock failures in runtime due to this problem.
Medium term fix would be to carefully handle all IL replacements in the linker with regard to try/catch/filter records.
Ideally the long term fix would be to do this in Cecil in such a way that IL replacements would be correctly handled on their own.
This fixes the
Http3RequestStream
failures mentioned in #2181, but I was not able to confirm if this fixes the CoreLib ArrayPool issues as well (I think it will not).