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

Startup crash with Release configuration on device #8789

Closed
filipnavara opened this issue Mar 6, 2024 · 1 comment · Fixed by #8790
Closed

Startup crash with Release configuration on device #8789

filipnavara opened this issue Mar 6, 2024 · 1 comment · Fixed by #8790
Assignees
Labels
Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned.

Comments

@filipnavara
Copy link
Member

Android application type

.NET Android (net7.0-android, net8.0-android, etc.)

Affected platform version

8.0.200, 8.0.300-preview.24108.16

Description

Application crashes on startup with the following error:

03-06 14:57:32.889 30371 30371 F DEBUG   : Cmdline: com.emclient.mailclient
03-06 14:57:32.889 30371 30371 F DEBUG   : pid: 23427, tid: 23427, name: ient.mailclient  >>> com.emclient.mailclient <<<
03-06 14:57:32.889 30371 30371 F DEBUG   : uid: 10473
03-06 14:57:32.889 30371 30371 F DEBUG   : signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x000000734f44c668
03-06 14:57:32.889 30371 30371 F DEBUG   :     x0  0000000000000000  x1  0000007fea518510  x2  b4000073db02a500  x3  0000000000000000
03-06 14:57:32.889 30371 30371 F DEBUG   :     x4  0000000000000002  x5  0000000000000000  x6  0000000000047dd9  x7  0000000000004000
03-06 14:57:32.889 30371 30371 F DEBUG   :     x8  0000000000000744  x9  000000734f449ad8  x10 00000000000003a1  x11 0000000000000572
03-06 14:57:32.889 30371 30371 F DEBUG   :     x12 0000009200000074  x13 00000073ac7f5000  x14 fffffffffc000000  x15 0000000000000020
03-06 14:57:32.889 30371 30371 F DEBUG   :     x16 00000073557a5590  x17 00000073556936dc  x18 0000007486702000  x19 b4000073db02a500
03-06 14:57:32.889 30371 30371 F DEBUG   :     x20 6b0ff375198b9c17  x21 000000000000039c  x22 00000073b485a948  x23 0000000000000001
03-06 14:57:32.889 30371 30371 F DEBUG   :     x24 00000073b485aa6c  x25 000000734f48e8b0  x26 00000074857c1000  x27 000000734f497080
03-06 14:57:32.889 30371 30371 F DEBUG   :     x28 000000734f48f9c4  x29 0000007fea518820
03-06 14:57:32.889 30371 30371 F DEBUG   :     lr  00000073b48335ec  sp  0000007fea518560  pc  00000073b483362c  pst 0000000020001000
03-06 14:57:32.889 30371 30371 F DEBUG   : backtrace:
03-06 14:57:32.889 30371 30371 F DEBUG   :       #00 pc 000000000001a62c  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmono-android.release.so (xamarin::android::internal::EmbeddedAssemblies::open_from_bundles_full(_MonoAssemblyName*, char**, void*)+6676) (BuildId: 29b6b17deb69ead9812e93161fff1e8c50fe531d)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #01 pc 00000000001fe67c  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #02 pc 00000000001fe858  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #03 pc 00000000001f9b20  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmonosgen-2.0.so (mono_init+268) (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #04 pc 00000000000c44f0  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmonosgen-2.0.so (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #05 pc 0000000000119570  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmonosgen-2.0.so (mono_jit_init_version+16) (BuildId: b4eabab966ddf1c49d3c8b923cca5b14598b39f3)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #06 pc 0000000000020cc8  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmono-android.release.so (xamarin::android::internal::MonodroidRuntime::create_domain(_JNIEnv*, xamarin::android::jstring_array_wrapper&, bool, bool)+216) (BuildId: 29b6b17deb69ead9812e93161fff1e8c50fe531d)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #07 pc 0000000000023f84  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmono-android.release.so (xamarin::android::internal::MonodroidRuntime::create_and_initialize_domain(_JNIEnv*, _jclass*, xamarin::android::jstring_array_wrapper&, xamarin::android::jstring_array_wrapper&, _jobjectArray*, xamarin::android::jstring_array_wrapper&, _jobject*, bool, bool, bool)+52) (BuildId: 29b6b17deb69ead9812e93161fff1e8c50fe531d)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #08 pc 0000000000027360  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmono-android.release.so (xamarin::android::internal::MonodroidRuntime::Java_mono_android_Runtime_initInternal(_JNIEnv*, _jclass*, _jstring*, _jobjectArray*, _jstring*, _jobjectArray*, int, _jobject*, _jobjectArray*, int, unsigned char, unsigned char)+3932) (BuildId: 29b6b17deb69ead9812e93161fff1e8c50fe531d)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #09 pc 000000000002a0f4  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/split_config.arm64_v8a.apk!libmono-android.release.so (Java_mono_android_Runtime_initInternal+88) (BuildId: 29b6b17deb69ead9812e93161fff1e8c50fe531d)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #10 pc 0000000000461d54  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #11 pc 0000000000209b68  /apex/com.android.art/lib64/libart.so (nterp_helper+2152) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #12 pc 00000000003d5cfa  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/base.apk (mono.MonoPackageManager.LoadApplication+402)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #13 pc 0000000000209398  /apex/com.android.art/lib64/libart.so (nterp_helper+152) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #14 pc 00000000003d5e56  /data/app/~~JtN6LJphqYlSbPBGzIIBUA==/com.emclient.mailclient-yOXhDm3E6hkYfbaQ_rK5UA==/base.apk (mono.MonoRuntimeProvider.attachInfo+70)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #15 pc 00000000002d5380  /system/framework/arm64/boot-framework.oat (android.app.ActivityThread.installProvider+2352) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #16 pc 00000000002d4840  /system/framework/arm64/boot-framework.oat (android.app.ActivityThread.installContentProviders+608) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #17 pc 00000000002cbf3c  /system/framework/arm64/boot-framework.oat (android.app.ActivityThread.handleBindApplication+6028) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #18 pc 00000000002c0440  /system/framework/arm64/boot-framework.oat (android.app.ActivityThread$H.handleMessage+7024) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #19 pc 000000000053c650  /system/framework/arm64/boot-framework.oat (android.os.Handler.dispatchMessage+192) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #20 pc 000000000053fa48  /system/framework/arm64/boot-framework.oat (android.os.Looper.loopOnce+1080) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #21 pc 000000000053f570  /system/framework/arm64/boot-framework.oat (android.os.Looper.loop+560) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #22 pc 00000000002d7374  /system/framework/arm64/boot-framework.oat (android.app.ActivityThread.main+1364) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #23 pc 0000000000458600  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+576) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #24 pc 000000000048b39c  /apex/com.android.art/lib64/libart.so (_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1560) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #25 pc 000000000048ad5c  /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) (.__uniq.165753521025965369065708152063621506277)+48) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #26 pc 0000000000099148  /system/framework/arm64/boot.oat (art_jni_trampoline+120) (BuildId: debc37f6712dda3ab8bc669477a0d38bc3726cb5)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #27 pc 000000000072ee40  /system/framework/arm64/boot-framework.oat (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+144) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #28 pc 000000000073818c  /system/framework/arm64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+3228) (BuildId: 5130deedb780d117e520fa98f378aa481d4d1e94)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #29 pc 0000000000458600  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+576) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #30 pc 0000000000589dfc  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+912) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #31 pc 0000000000606de4  /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+160) (BuildId: 4c9b59b74ca9272f710a71137164c349)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #32 pc 00000000000c0c04  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+124) (BuildId: e08be775c0c45f9f337c34336ac8f7c5)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #33 pc 00000000000cd80c  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+924) (BuildId: e08be775c0c45f9f337c34336ac8f7c5)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #34 pc 0000000000002610  /system/bin/app_process64 (main+1464) (BuildId: 0392f54b3dffeef9b6cad14b6f0bdd45)
03-06 14:57:32.889 30371 30371 F DEBUG   :       #35 pc 00000000000859b8  /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+100) (BuildId: 449f781894033dce6346794a1ee593e0)

Steps to Reproduce

No easy steps, happened on a big app after updating to .NET 8 from .NET 7.

.csproj options:

  <PropertyGroup>
    <TargetFramework>net8.0-android</TargetFramework>
    <OutputType>Exe</OutputType>
    <RootNamespace>MailClient.Mobile.Droid</RootNamespace>
    <AssemblyName>MailClient.Mobile.Android</AssemblyName>
    <Deterministic>True</Deterministic>
    <AndroidApplication>True</AndroidApplication>
    <AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
    <AndroidResgenClass>Resource</AndroidResgenClass>
    <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
    <!-- All resources are included automatically via the SDK, no need to enumerate them explicitly via ItemGroup(s). Additionally 'Resources' is the default value, so even MonoAndroidResourcePrefix is redundant here.  -->
    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
    <AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
    <AndroidUseAapt2>true</AndroidUseAapt2>
    <UseNativeHttpHandler>false</UseNativeHttpHandler>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
    <LangVersion>latest</LangVersion>
    <GenerateApplicationManifest>true</GenerateApplicationManifest>
    <_ResolveMonoAndroidSdksDependsOn Condition="'$(DesignTimeBuild)' != 'true'">GenerateAssemblyNBGVVersionInfo</_ResolveMonoAndroidSdksDependsOn>
    <AndroidApplication>true</AndroidApplication>
    <SupportedOSPlatformVersion>23.0</SupportedOSPlatformVersion>
    <UseMauiAssets>true</UseMauiAssets>

	  <!-- <AndroidEnableProfiler>true</AndroidEnableProfiler> -->
  </PropertyGroup>

  <PropertyGroup>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <NoWarn>;CS8632;NU1608;NU1605;MSB3277;NU1701;CA1422</NoWarn>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>portable</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug</OutputPath>
    <DefineConstants>DEBUG;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidLinkMode>None</AndroidLinkMode>
    <RunAOTCompilation>false</RunAOTCompilation>
    <EnableLLVM>false</EnableLLVM>
    <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
    <BundleAssemblies>false</BundleAssemblies>
    <EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
    <AndroidUseAapt2>True</AndroidUseAapt2>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>portable</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidManagedSymbols>true</AndroidManagedSymbols>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
    <AndroidEnableProfiledAot>true</AndroidEnableProfiledAot>
    <AndroidUseDefaultAotProfile>false</AndroidUseDefaultAotProfile>
    <RunAOTCompilation>true</RunAOTCompilation>
    <EnableLLVM>false</EnableLLVM>
    <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
    <AndroidUseAapt2>True</AndroidUseAapt2>
  </PropertyGroup>

Did you find any workaround?

No

Relevant log output

Logcat: https://gist.github.com/filipnavara/fc23e7c5a0dbaca60e5f01f8b1280c2e
@filipnavara filipnavara added Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned. labels Mar 6, 2024
@filipnavara
Copy link
Member Author

Workaround in .csproj:

<Target Name="_GeneratePackageManagerJavaHack" BeforeTargets="_GeneratePackageManagerJava">
    <ItemGroup>
      <_AndroidResolvedSatellitePaths Update="@(_AndroidResolvedSatellitePaths)">
        <RelativePath>%(DestinationSubDirectory)%(FileName)%(Extension)</RelativePath>
      </_AndroidResolvedSatellitePaths>
    </ItemGroup>
  </Target>

grendello added a commit that referenced this issue Mar 6, 2024
Fixes: #8789

The old method of satellite assembly counting relied on the
`RelativePath` MSBuild item metadata, which appears to have gone
missing somewhere in .NET8+.  Update the code to check for presence
of the following metadata, in order given, to determine assembly's
culture, if any:

  * `Culture`
  * `RelativePath`
  * `DestinationSubDirectory`

Failure to count satellite assemblies can, and sometimes will,
result in a segfault since we generate a number of native code
arrays based on the assembly count and the runtime assumes that
what the build told it is true.
jonpryor pushed a commit that referenced this issue Mar 22, 2024
Fixes: #8789

The old method of satellite assembly counting relied on the
`RelativePath` MSBuild item metadata, which appears to have gone
missing somewhere in .NET8+.  Update the code to check for presence
of the following metadata, in order given, to determine assembly's
culture, if any:

  * `Culture`
  * `RelativePath`
  * `DestinationSubDirectory`

Failure to count satellite assemblies can, and sometimes will,
result in a segfault since we generate a number of native code
arrays based on the assembly count and the runtime assumes that
what the build told it is true.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants