Skip to content
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

[monodroid] Properly process satellite assemblies #7823

Merged
merged 5 commits into from
Feb 28, 2023

Commits on Feb 22, 2023

  1. [monodroid] Properly process satellite assemblies

    Fixes: dotnet#7819
    
    Our native runtime uses a cache of pointers to loaded managed assembly
    images (essentially an array of the native struct `MonoImage` pointers)
    which is pre-allocated at build time and placed in the native
    `libxamarin-app.so` library.
    
    While generating the cache, we also generate hashes for a number of
    assembly name permutations (currently two per assembly - with and
    without the extension).  Only unique assembly names are considered when
    generating the cache (it's possible to have duplicate names, because we
    package more than one copy of some assemblies - those which are
    architecture specific).  This algorithm had a bug which made it ignore
    culture prefix in satellite assembly names (e.g.
    `en/MyAssembly.resources.dll`) and instead of several entries for each
    culture, we generated only two entries for `MyAssembly.resources.dll`
    and `MyAssembly.resources` but we still counted each culture-prefixed
    assembly and stored that number in `libxamarin-app.so` to be used at
    runtime to calculate number of entries in the cache.
    
    This made the array storing cached `MonoImage*` pointers to be smaller
    than the number of actual assemblies in the APK times 2 and in some
    cases we failed to look up pointer to some images and, as the result,
    passed a `NULL` pointer to MonoVM which then caused a segmentation fault
    trying to dereference the pointer.
    
    Stop ignoring the culture prefix for satellite assemblies in order to
    avoid the situation.  Additionally, since the previous assumption that
    MonoVM will validate all pointers passed to its APIs turned out to be
    unwarranted, we now check more carefully for `NULL` pointers when trying
    to obtain a native function pointer from the MonoVM runtime.
    grendello committed Feb 22, 2023
    Configuration menu
    Copy the full SHA
    24a7e81 View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2023

  1. Test(s)

    Add a test for the issue, based on the
    `MissingSatelliteAssemblyInLibrary` packaging test which, when it fails,
    will result in a `SIGABRT`:
    
        D monodroid-assembly: assembly_store_open_from_bundles: looking for bundled name: 'System.Private.CoreLib' (hash 0x6b0ff375198b9c17)
        F monodroid-assembly: Invalid assembly index 19, exceeds the maximum index of 11
        F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 17957 (semblyinlibrary), pid 17957 (semblyinlibrary)
    
    Enhance the packaging test `MissingSatelliteAssemblyInLibrary` by adding
    more languages, to see if they're all packaged correctly.
    grendello committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    b475944 View commit details
    Browse the repository at this point in the history
  2. Fix the new test

    grendello committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    dab54df View commit details
    Browse the repository at this point in the history

Commits on Feb 27, 2023

  1. Merge branch 'main' into issue7819

    * main:
      Localized file check-in by OneLocBuild (dotnet#7827)
      Revert "Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)"
      LEGO: Merge pull request 7828
      LEGO: Merge pull request 7825
      Bump to xamarin/Java.Interop/main@bbaeda6f (dotnet#7799)
      Bump NDK to r25c (dotnet#7808)
      [Xamarin.Android.Build.Tests] Improve logcat logging in failed tests (dotnet#7816)
      [Mono.Android] Update api-compat reference file for current API-33 (dotnet#7822)
    grendello committed Feb 27, 2023
    Configuration menu
    Copy the full SHA
    1b1df89 View commit details
    Browse the repository at this point in the history
  2. Use the builder field in the test

    Also, set `builder` to `null` after a test is done
    grendello committed Feb 27, 2023
    Configuration menu
    Copy the full SHA
    dde53ee View commit details
    Browse the repository at this point in the history