Fix broken try/catch/filter offsets after isinst optimization#2205
Fix broken try/catch/filter offsets after isinst optimization#2205vitek-karas merged 5 commits intodotnet:mainfrom
Conversation
|
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, ldnullwhen 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 oldisinstinstruction 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
Http3RequestStreamfailures mentioned in #2181, but I was not able to confirm if this fixes the CoreLib ArrayPool issues as well (I think it will not).