-
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
linker producing bad code in finally block that causes AOT compiler to seg fault #2181
Comments
What should be simple repro steps - requires macOS (I wasn't able to validate that it does repro yet): Latest dotnet/runtime repo clone ./build.sh -Subset mono+libs -os iOSSimulator -arch x64
./dotnet.sh build /t:Test src/tests/FunctionalTests/iOS/Simulator/AOT /p:TargetOS=iOSSimulator /p:TargetArchitecture=x64 The last command should fail to AOT compile. |
Just an update. The underlying problem is:
Mono AOT compiler is obviously sensitive to such corruption. The case of the Unfortunately there are other places where linker edits the method body which all have similar issues. One such place is constant propagation and branch removal - which is what feature switches rely on. That's probably where the CoreLib/ArrayPool issue is - but we were not able to get a repro of that to validate the theory. We don't have a candidate fix for the feature switch corruption (nor we have a direct repro - even a constructed one, just yet). |
The issue with |
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.
#2213 fixes all of the problems known in this area (and tries to prevent any similar problem in the future). |
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.
Trying to revert both. The Http3RequestStream is definitely fixed by the linker changes. The ArrayPool ones probably not, but trying to get a repro.
* Revert workarounds for dotnet/linker#2181 Trying to revert both. The Http3RequestStream is definitely fixed by the linker changes. The ArrayPool ones probably not, but trying to get a repro. * Fully revert ArrayPool workaround
Closing, as it looks like this is fixed. |
…/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
See dotnet/runtime#56316 (comment).
The text was updated successfully, but these errors were encountered: