Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

NativeAOT: a fatal managed exception on the main thread leaves the process alive (propagateUncaughtException has no native implementation)

Abierto
#13,141 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
18/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
android, c, csharp, java

Línea de trabajo

The failing lookup is the native propagateUncaughtException declared in src/java-runtime/java/mono/android/Runtime.java; the CoreCLR counterpart is in src/native/clr/host/host-jni.cc. Start by finding where the NativeAOT runtime should provide the matching JNI symbol and why it is missing. Done would mean a fatal managed exception on the main thread terminates the process under PublishAot, confirmed by the repro in the issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

needs-triage
Android framework version

net10.0-android

Affected platform version

.NET SDK 10.0.401, Microsoft.Android.Sdk 36.1.69, PublishAot=true, android-x64 on an API 35 emulator (Google APIs Play Store x86_64 image). I have not tried arm64.

Description

With NativeAOT, an unhandled managed exception on the main thread does not terminate the app. The process stays alive (adb shell ps still lists it), the UI stays wherever it was, and the crash dialog never shows. The same app built without PublishAot dies as expected.

The managed exception is logged as a FATAL EXCEPTION: main from AndroidRuntime (a JavaProxyThrowable wrapping the managed exception), then logcat shows:

E ame.ZombieRepro: No implementation found for void mono.android.Runtime.propagateUncaughtException(java.lang.Thread, java.lang.Throwable) (tried Java_mono_android_Runtime_propagateUncaughtException and Java_mono_android_Runtime_propagateUncaughtException__Ljava_lang_Thread_2Ljava_lang_Throwable_2) - is the library loaded, e.g. System.loadLibrary?

propagateUncaughtException is declared native in src/java-runtime/java/mono/android/Runtime.java. The CoreCLR host exports it (src/native/clr/host/host-jni.cc, libnet-android.map.txt). I could not find a NativeAOT counterpart by code search (not stepped through, happy to be corrected). So the JNI lookup fails and the default handler never kills the process.

The same log line is pasted in a comment in tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs (the NativeAOT branch of AppWithStyleableUsageRuns), so the existing tests hit it too.

Impact: a startup crash looks like a hang. Anything that detects crashes by process death never sees one. We only found this because our CI waited out its whole job timeout.

Related: #10657 / #10658 (the CoreCLR equivalent, closed) and the NativeAOT TODO list #9784 (it mentions that AppDomain.CurrentDomain.UnhandledException is skipped under NativeAOT). I found no issue covering this symptom.

Steps to Reproduce

Verified on a blank app, no third-party packages.

  1. dotnet new android -n ZombieRepro
  2. In ZombieRepro.csproj add:
    <PublishAot>true</PublishAot>
    <RuntimeIdentifier>android-x64</RuntimeIdentifier>
    
  3. In MainActivity.OnCreate, before anything else: throw new InvalidOperationException("boom");
  4. dotnet publish -c Release -f net10.0-android (needs an NDK clang on PATH and -p:AndroidNdkDirectory=<ndk>), then adb install the -Signed.apk and launch it.
  5. Wait about 15 seconds. adb shell ps -A | grep -i zombie still lists the process (state S), and adb logcat -d | grep propagateUncaughtException shows the "No implementation found" line.
  6. Set PublishAot to false, rebuild, reinstall, launch: the process is gone after the same wait and only the FATAL EXCEPTION is logged.
Did you find any workaround?

Detect the crash from adb logcat -d -b crash (Process: <appid>, lines) instead of process death. An in-app option might be to hook AppDomain.CurrentDomain.UnhandledException and call Process.KillProcess(Process.MyPid()), but I haven't tried it, and #9784 says that event is skipped under NativeAOT.

Relevant log output
E AndroidRuntime: FATAL EXCEPTION: main
E AndroidRuntime: Process: com.companyname.ZombieRepro, PID: 4449
E AndroidRuntime: net.dot.jni.internal.JavaProxyThrowable: System.InvalidOperationException: boom
E AndroidRuntime:    at ZombieRepro.MainActivity.OnCreate(Bundle savedInstanceState) + 0x27
...
E ame.ZombieRepro: No implementation found for void mono.android.Runtime.propagateUncaughtException(java.lang.Thread, java.lang.Throwable) ...
Lenguaje dominante
C#
Estrellas
2.1k
Forks
581
Merge medio
1 d 21 h
PR fusionados (30 d)
241

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/android

Todos los issues de dotnet/android

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.