Skip to content

[Android <4.3] AOT + SO_MAX=128 limitation leads to crash on start. #1146

Closed

Description

@Belorus

Androids pre 4.3 allowed only 128 .so libraries loaded into one process.
https://android.googlesource.com/platform/bionic/+/android-4.2_r1/linker/linker.cpp#54

OS + Runtime normally load about 65 libraries even before first line of code executes.
Other libs like mscorlib, System.Core, System.Net.Http take other ~20.

If your solution has ~20-25 projects (which isn't too much if you have proper architecture), and has another 10-15 nuget references - app won't load.

Repro project that simply loads hundred of native libs and crashes after 56

Log will contain entries like that, and crash with some DllNotFoundException

D/Mono    ( 6456): DllImport error loading library './libUnluckyLibName.so': 'Cannot load library: alloc_info[268]:   195 too many libraries when loading libUnluckyLibName.so'.

There is a cool solution that embeds all .dll files into one app_bundle.so.
If something like that was implemented for AOT mode (for .so files), that would be great.

Activity

  1. jonpryor commented on Jan 2, 2018

    @jonpryor
    Contributor

    Upstream feature request: mono/mono#6370

  2. jonpryor commented on Jan 2, 2018

    @jonpryor
    Contributor

    @Belorus: Looking at your Repro project, even if/when mono supports emitting a single AOT .so for all assemblies, your repro project will still fail, as ClassLibrary1/ClassLibrary1.csproj contains 135 native libraries, none of which can be merged/unified as part of AOT.

    It might be more useful to create a repro which actually results in AOT native libraries preventing the launching of the app, not ~arbitrary native libraries packaged with the app.

  3. Belorus commented on Jan 2, 2018

    @Belorus
    Author

    True, repro only shows the OS limitation and was used to calculate amount of hidden libraries loaded even before user code is run, it isn't a real red/green checker for the issue.
    I'll create a proper one a bit later.

    Thanks for quick response!

  4. jpobst commented on Mar 4, 2021

    @jpobst
    Contributor

    Given that the minimum supported Android in Xamarin.Android is now 4.4, this no longer seems relevant.

  5. ghost locked as resolved and limited conversation to collaborators on Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions