NativeAOT: a fatal managed exception on the main thread leaves the process alive (propagateUncaughtException has no native implementation)
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
- Área
- mobile-dev, operating-systems
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
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.
dotnet new android -n ZombieRepro- In
ZombieRepro.csprojadd:<PublishAot>true</PublishAot> <RuntimeIdentifier>android-x64</RuntimeIdentifier> - In
MainActivity.OnCreate, before anything else:throw new InvalidOperationException("boom"); dotnet publish -c Release -f net10.0-android(needs an NDKclangonPATHand-p:AndroidNdkDirectory=<ndk>), thenadb installthe-Signed.apkand launch it.- Wait about 15 seconds.
adb shell ps -A | grep -i zombiestill lists the process (stateS), andadb logcat -d | grep propagateUncaughtExceptionshows the "No implementation found" line. - Set
PublishAotto false, rebuild, reinstall, launch: the process is gone after the same wait and only theFATAL EXCEPTIONis 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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnet/android
-
Area: App+Library Build
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
EditText.getText() isn't boundAbiertoArea: Mono.Android
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/android#9192 · 4 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Area: Mono.Android needs-triage
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
Area: App Runtime needs-triage
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
Los mantenedores suelen responder en 1 día
-
flaky-ci flaky-tests needs-triage
Dificultad 5/5 Más de una semana Aptitud para principiantes 8/100
Los mantenedores suelen responder en 1 día
Todos los issues de dotnet/android
Issues similares
-
area: design documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
eyalgolan/statecraft-israel#883 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 3 días
-
area/indexing bug package/core triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
enhancement needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
elastic/docs-builder#4495 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
protobuf-net/protobuf-net#1375 · 2 comentarios ·
Los mantenedores suelen responder en 2 días