[mono] Mark AOT modules unusable if no AOT version is found#106026
Merged
matouskozak merged 2 commits intodotnet:mainfrom Aug 7, 2024
Merged
[mono] Mark AOT modules unusable if no AOT version is found#106026matouskozak merged 2 commits intodotnet:mainfrom
matouskozak merged 2 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger |
Member
Author
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Aug 6, 2024
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
Member
Author
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
steveisok
approved these changes
Aug 6, 2024
Member
Author
|
The |
This was referenced Aug 7, 2024
jonpryor
pushed a commit
to dotnet/android
that referenced
this pull request
Aug 27, 2024
Fixes: #9081 Context: dotnet/runtime#104397 Context: dotnet/runtime#106026 Context: #9081 (comment) Context: c227042 ("Compatibility is fun") Consider a P/Invoke method declaration: [DllImport("libSkiaSharp")] static extern void gr_backendrendertarget_delete(IntPtr rendertarget); Historically, when attempting to resolve this method, Mono would try loading the following native libraries: * `libSkiaSharp` (original name) * `libSkiaSharp.so` (add `.so` suffix) * `liblibSkiaSharp` (add `lib` prefix) * `liblibSkiaSharp.so` (`lib` prefix + `.so` suffix) .NET for Android would further permute these names, *removing* the `lib` prefix, for attempted compatibility in case there is a P/Invoke into `"SkiaSharp"`. The unfortunate occasional result would be an *ambiguity*: when told to resolve "SkiaSharp", what should we return? The information for `libSkiaSharp.so`, or for the *AOT'd image* of the assembly `SkiaSharp.dll`, by way of `libaot-SkiaSharp.dll.so`? %struct.DSOCacheEntry { i64 u0x12e73d483788709d, ; from name: SkiaSharp.so i64 u0x3cb282562b838c95, ; uint64_t real_name_hash i1 false, ; bool ignore ptr @.DSOCacheEntry.23_name, ; name: libaot-SkiaSharp.dll.so ptr null; void* handle }, ; 71 %struct.DSOCacheEntry { i64 u0x12e73d483788709d, ; from name: SkiaSharp.so i64 u0x43db119dcc3147fa, ; uint64_t real_name_hash i1 false, ; bool ignore ptr @.DSOCacheEntry.7_name, ; name: libSkiaSharp.so ptr null; void* handle }, ; 72 If we return the wrong thing, then the app may crash or otherwise behave incorrectly. Fix this by: * Splitting up the DSO cache into AOT-related `.so` files and everything else. * Updating `PinvokeOverride::load_library_symbol()` so that the AOT files are *not* consulted when resolving P/Invoke libraries. * Updating `MonodroidDl::monodroid_dlopen()` -- which is called by MonoVM via `mono_dl_fallback_register()` -- so that the AOT files *are* consulted *first* when resolving AOT images. When dotnet/runtime#104397 is fixed, it will make the AOT side of the split more efficient as we won't have to permute the shared library name as many times as now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On Android, we might hit a collision where we instead of
<libName>.dll.sotry to load<libName>.so. By detecting this issue early we can mark the library as AOT unusable. We do this by checking if we were able to get the AOT file version and if not, we mark the.sofile as unusable.Full issue description #104397.
This is a fix from #104397 (comment). cc: @lambdageek
Verification
Tried locally build runtime with Xamarin Android app previously crashing due to SkiaSharp load. The crash wasn't present with this PR and the app started up correctly.
Previous behavior:
This PR: