-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[illink] Assert when running analysis on code produced by custom step for iOS, collision on IL offsets #110753
Comments
Tagging subscribers to this area: @dotnet/illink |
/cc @simonrozsival I don't know what the best fix would be (other than removing custom steps :-)). |
This is ultimately also the cause of the exception in #110714 (we ignore the asserts in release and will try to merge argument lists with different number of arguments). |
xamarin/xamarin-macios@main...vitek-karas:xamarin-macios:ILOffsets contains the workaround for iOS custom steps. It generates unique IL offsets for all instructions in methods generated by the custom step. I'm curious what you think should be the fix: @simonrozsival , @sbomer |
Note that Android custom steps might have similar problem, but from a quick look they don't do so much code generation in the custom steps (but there is some of it happening). |
I think we should take your fix to the custom step. Generating IL with correct IL offsets seems like the safest way to ensure things don't go wrong downstream (short of removing/replacing the custom step). |
This method in a custom step: https://github.com/xamarin/xamarin-macios/blob/84cb6e794e315f2b037c35fc96efe36fc9d84f6b/tools/dotnet-linker/Steps/ManagedRegistrarStep.cs#L1333
adds code into the assembly via IL emitter. Later on we will run data flow analysis on the method body.
Whenever there's a
call
instruction we record it viaTrimAnalysisMethodCallPattern
. These patterns are stored in a dictionary in https://github.com/xamarin/xamarin-macios/blob/84cb6e794e315f2b037c35fc96efe36fc9d84f6b/tools/dotnet-linker/Steps/ManagedRegistrarStep.cs#L1333. The key to the dictionary is theMessageOrigin
. TheMessageOrigin
identity is defined asProvider
,ILOffset
, ... (in this order). So for two calls from the same method the two origins will be identical except for theILOffset
.The problem is, that IL emitter doesn't assign IL offsets to the generated instructions, so in the custom step generated body all instructions has offset of
0
. Thus we end up in the situation where two different method calls have identicalMessageOrigin
.This will eventually produce an assert in
runtime/src/tools/illink/src/linker/Linker.Dataflow/TrimAnalysisMethodCallPattern.cs
Line 47 in 373f048
The text was updated successfully, but these errors were encountered: