You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[monodroid] Disable loading of libLLVM at runtime (#7499)
Context: xamarin/monodroid@d887d87d8f
Context: llvm/llvm-project@c10ca90
Way back in 2014-Feb-26, private bug [#18016][0] was filed against
Xamarin.Android 4.10.2: when a project contained RenderScript and ran
on an Android 4.0.4 device, it could eventually hang. No exception,
no error message, no nothing.
After investigation, the cause of the hang was that the RenderScript
compiler would use the same Unix signals as the Mono for Android GC,
and did not properly chain those signals. Thus, if the on-device
RenderScript compiler hit particular code paths which caused it to
register those Unix signals, the Mono for Android GC would no longer
work from that point onward.
It was determined that the `llvm::DisablePrettyStackTrace` global
variable within `libLLVM.so` could control this behavior.
The "fix"/workaround was to *prevent* the RenderScript compiler from
subscribing to those Unix signals by:
1. Loading `libLLVM.so` at runtime,
2. Looking for the symbol `_ZN4llvm23DisablePrettyStackTraceE`, which
is the name mangled form of `bool llvm::DisablePrettyStackTrace`.
3. Set the value to 1/`true`.
xamarin/monodroid@d887d87d8f commit message contents:
> Disable LLVM signal handlers. Fixes #18016.
>
> This happens when RenderScript needs to be compiled.
> See https://bugzilla.xamarin.com/show_bug.cgi?id=18016
>
> This happens only on first run of the app. LLVM is used to compiled
> the RenderScript scripts. LLVM, been a nice and smart library
> installs a ton of signal handlers and don't chain at all, completely
> breaking us.
>
> This is a hack to set llvm::DisablePrettyStackTrace to true and
> avoid this source of signal handlers.
The `llvm::DisablePrettyStackTrace` variable was *removed* from LLVM
in 2013-Nov-3 via llvm/llvm-project@c10ca903, but Android continued
to redistribute a version of LLVM which contained that symbol until
Android 5.0 / API-21.
Update `MonodroidRuntime::disable_external_signal_handlers()` to
do nothing for .NET 6+ -- as .NET 6 has API-21 as a minimum API level
-- and update Classic Xamarin.Android to only look for
`libLLVM.so!_ZN4llvm23DisablePrettyStackTraceE` on pre-API-21
targets.
This removes the warning message:
Failed to load shared library 'libLLVM.so'
when running .NET Android apps.
[0]: https://bugzilla.xamarin.com/18/18016/bug.html
0 commit comments