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

Crash with Android x86 emulator and Microsoft CognitiveServices Speech Xamarin quickstart #3989

Closed
jhakulin opened this issue Dec 4, 2019 · 7 comments
Assignees
Labels
Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc.

Comments

@jhakulin
Copy link

jhakulin commented Dec 4, 2019

Steps to Reproduce

  1. Download Microsoft.CognitiveServices.Speech SDK helloworld Xamarin quickstart from https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/quickstart/csharp/xamarin
  2. Build the solution and start debugging it on Android x86 emulator
  3. After app is launched, press "Enable Microphone" button and agree with consent and then press "Start Speech Recognition" button

Expected Behavior

App would start speech recognition and would not crash

Actual Behavior

App crashes based on my analysis in mono runtime, root cause is not known.

signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #00 pc 00061c1d /data/app/com.companyname.helloworld-H1H87jywCueoKLIVJQIepQ==/lib/x86/libmonosgen-2.0.so (mono_spill_global_vars+61): Routine mono_spill_global_vars at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mono/mini/method-to-ir.c:11944
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #1 pc 0001f1b0 /data/app/com.companyname.helloworld-H1H87jywCueoKLIVJQIepQ==/lib/x86/libmonosgen-2.0.so (mini_method_compile+8048): Routine mini_method_compile at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mono/mini/mini.c:3791
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #2 pc 000208d0 /data/app/com.companyname.helloworld-H1H87jywCueoKLIVJQIepQ==/lib/x86/libmonosgen-2.0.so (mono_jit_compile_method_inner+64): Routine mono_jit_compile_method_inner at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mono/mini/mini.c:4036
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #3 pc 00024645 /data/app/com.companyname.helloworld-H1H87jywCueoKLIVJQIepQ==/lib/x86/libmonosgen-2.0.so (mono_jit_compile_method_with_opt+2901): Routine mono_jit_compile_method_with_opt at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mono/mini/mini-runtime.c:2434
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #4 pc 00023ae4 /data/app/com.companyname.helloworld-H1H87jywCueoKLIVJQIepQ==/lib/x86/libmonosgen-2.0.so (mono_jit_compile_method+52): Routine mono_jit_compile_method at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mono/mini/mini-runtime.c:2484
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #5 pc 000c2094 /data/app/com.companyname.helloworld-H1H87jywCueoKLIVJQIepQ==/lib/x86/libmonosgen-2.0.so (common_call_trampoline+1156): Routine common_call_trampoline at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mono/mini/mini-trampolines.c:635
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #6 pc 000c1bb1 /data/app/com.companyname.helloworld-H1H87jywCueoKLIVJQIepQ==/lib/x86/libmonosgen-2.0.so (mono_magic_trampoline+97): Routine mono_magic_trampoline at /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mono/mini/mini-trampolines.c:773
Stack frame 12-03 16:29:16.257 6686 6686 F DEBUG : #7 pc 00010187 anonymous:e7890000: Unable to open symbol file C:\Work\com.companyname.helloworld3\lib\x86/anonymous:e7890000. Error (22): Invalid argument

Version Information

Microsoft Visual Studio Enterprise 2019
Version 16.4.0
VisualStudio.16.Release/16.4.0+29519.181
Microsoft .NET Framework
Version 4.8.03752

Xamarin.Android SDK 10.1.0.30 (d16-4/5e2fd06)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: e1ef774
Java.Interop: xamarin/java.interop/d16-4@c4e569f
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@46204c4
Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b

Log File

  1. Paste below this comment block
    -->

ndk-stack-dump.txt

logcat-crash.txt

@pjcollins
Copy link
Member

I was able to reproduce this with d16-4 after creating a new Android 9.0 x86 emulator:

12-05 17:25:14.757  7565  7565 D Mono    : Loading reference 3 of /storage/emulated/0/Android/data/com.companyname.kws_xamarin/files/.__override__/kws-xamarin.dll asmctx DEFAULT, looking for Microsoft.CognitiveServices.Speech.csharp, Version=1.8.0.28, Culture=neutral, PublicKeyToken=d2e6dcccb609e663
12-05 17:25:14.757  7565  7565 D Mono    : Assembly Ref addref kws-xamarin[0xdc69e240] -> Microsoft.CognitiveServices.Speech.csharp[0xdc69e300]: 2
12-05 17:25:14.768  7565  7565 D Mono    : DllImport attempting to load: 'libMicrosoft.CognitiveServices.Speech.core.so'.
12-05 17:25:14.769  7565  7565 D Mono    : DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.kws_xamarin/files/.__override__/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-05 17:25:14.769  7565  7565 I chatty  : uid=10088(com.companyname.kws_xamarin) identical 1 line
12-05 17:25:14.769  7565  7565 D Mono    : DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.kws_xamarin/files/.__override__/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-05 17:25:14.769  7565  7565 D Mono    : DllImport error loading library '/system/lib/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-05 17:25:14.769  7565  7565 I chatty  : uid=10088(com.companyname.kws_xamarin) identical 1 line
12-05 17:25:14.769  7565  7565 D Mono    : DllImport error loading library '/system/lib/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-05 17:25:14.794  7565  7565 D Mono    : DllImport loaded library 'libMicrosoft.CognitiveServices.Speech.core.so'.
12-05 17:25:14.794  7565  7565 D Mono    : DllImport searching in: 'libMicrosoft.CognitiveServices.Speech.core.so' ('libMicrosoft.CognitiveServices.Speech.core.so').
12-05 17:25:14.794  7565  7565 D Mono    : Searching for 'speech_config_from_subscription'.
12-05 17:25:14.794  7565  7565 D Mono    : Probing 'speech_config_from_subscription'.
12-05 17:25:14.794  7565  7565 D Mono    : Found as 'speech_config_from_subscription'.
12-05 17:25:14.799  7565  7565 D Mono    : DllImport searching in: 'libMicrosoft.CognitiveServices.Speech.core.so' ('libMicrosoft.CognitiveServices.Speech.core.so').
12-05 17:25:14.799  7565  7565 D Mono    : Searching for 'speech_config_get_property_bag'.
12-05 17:25:14.799  7565  7565 D Mono    : Probing 'speech_config_get_property_bag'.
12-05 17:25:14.799  7565  7565 D Mono    : Found as 'speech_config_get_property_bag'.
--------- beginning of crash
12-05 17:25:14.802  7565  7565 F libc    : Fatal signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0 in tid 7565 (ame.kws_xamarin), pid 7565 (ame.kws_xamarin)
12-05 17:25:14.853  7602  7602 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
12-05 17:25:14.853  1787  1787 I /system/bin/tombstoned: received crash request for pid 7565
12-05 17:25:14.853  7602  7602 I crash_dump32: performing dump of process 7565 (target tid = 7565)
12-05 17:25:14.857  7602  7602 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-05 17:25:14.858  7602  7602 F DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_arm/generic_x86_arm:9/PSR1.180720.117/5875966:user/release-keys'
12-05 17:25:14.858  7602  7602 F DEBUG   : Revision: '0'
12-05 17:25:14.858  7602  7602 F DEBUG   : ABI: 'x86'
12-05 17:25:14.858  7602  7602 F DEBUG   : pid: 7565, tid: 7565, name: ame.kws_xamarin  >>> com.companyname.kws_xamarin <<<
12-05 17:25:14.858  7602  7602 F DEBUG   : signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0
12-05 17:25:14.858  7602  7602 F DEBUG   :     eax 4d0cdf5f  ebx cb2b0b64  ecx ffd17ed8  edx c6843300
12-05 17:25:14.858  7602  7602 F DEBUG   :     edi e7434d9c  esi c6843300
12-05 17:25:14.858  7602  7602 F DEBUG   :     ebp 00000001  esp ffd17bc8  eip caf72c1d
12-05 17:25:14.859  7602  7602 F DEBUG   : 
12-05 17:25:14.859  7602  7602 F DEBUG   : backtrace:
12-05 17:25:14.859  7602  7602 F DEBUG   :     #00 pc 00061c1d  /data/app/Mono.Android.DebugRuntime-sBelA39TYFLYsQLJlWuCJA==/lib/x86/libmonosgen-32bit-2.0.so
12-05 17:25:14.963  1787  1787 E /system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_02
--------- beginning of system
12-05 17:25:14.971  1924  7605 W ActivityManager:   Force finishing activity com.companyname.kws_xamarin/crc649f9cc9c17db6fc4e.MainActivity

@grendello grendello assigned marek-safar and unassigned grendello and radekdoulik Dec 6, 2019
@grendello grendello added Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc. and removed Area: App Runtime Issues in `libmonodroid.so`. labels Dec 6, 2019
@grendello
Copy link
Contributor

The crash in OP suggests it's an issue with the Mono JIT.

@marek-safar marek-safar assigned SamMonoRT and unassigned marek-safar Dec 6, 2019
@SamMonoRT
Copy link
Member

@BrzVlad - please take a look at this one since you are already investigating other Android related bugs

@josephsctan
Copy link

Another snippet of information.

I have two apps trying to use SpeechConfig.FromSubscription() - one is a Xamarin Forms app and another one is a Xamarin Android app.

The Xamarin Android one crashes on an x86 Oreo 8.1 emulator

12-11 13:11:33.831 2692 2692 D Mono : DllImport attempting to load: 'libMicrosoft.CognitiveServices.Speech.core.so'.
12-11 13:11:33.831 2692 2692 D Mono : DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.helloworld2/files/.override/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:11:33.831 2692 2692 I chatty : uid=10067(com.companyname.helloworld2) identical 1 line
12-11 13:11:33.831 2692 2692 D Mono : DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.helloworld2/files/.override/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:11:33.831 2692 2692 D Mono : DllImport error loading library '/system/lib/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:11:33.831 2692 2692 I chatty : uid=10067(com.companyname.helloworld2) identical 1 line
12-11 13:11:33.831 2692 2692 D Mono : DllImport error loading library '/system/lib/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:11:33.938 2692 2692 D Mono : DllImport loaded library 'libMicrosoft.CognitiveServices.Speech.core.so'.
12-11 13:11:33.938 2692 2692 D Mono : DllImport searching in: 'libMicrosoft.CognitiveServices.Speech.core.so' ('libMicrosoft.CognitiveServices.Speech.core.so').
12-11 13:11:33.938 2692 2692 D Mono : Searching for 'speech_config_from_subscription'.
12-11 13:11:33.938 2692 2692 D Mono : Probing 'speech_config_from_subscription'.
12-11 13:11:33.938 2692 2692 D Mono : Found as 'speech_config_from_subscription'.
12-11 13:11:34.099 2692 2692 D Mono : DllImport searching in: 'libMicrosoft.CognitiveServices.Speech.core.so' ('libMicrosoft.CognitiveServices.Speech.core.so').
12-11 13:11:34.099 2692 2692 D Mono : Searching for 'speech_config_get_property_bag'.
12-11 13:11:34.099 2692 2692 D Mono : Probing 'speech_config_get_property_bag'.
12-11 13:11:34.099 2692 2692 D Mono : Found as 'speech_config_get_property_bag'.
--------- beginning of crash
12-11 13:11:34.108 2692 2692 F libc : Fatal signal 11 (SIGSEGV), code 128, fault addr 0x0 in tid 2692 (name.helloworld2), pid 2692 (name.helloworld2)
12-11 13:11:34.137 2735 2735 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
12-11 13:11:34.137 1540 1540 I /system/bin/tombstoned: received crash request for pid 2692
12-11 13:11:34.138 2735 2735 I crash_dump32: performing dump of process 2692 (target tid = 2692)
12-11 13:11:34.139 2735 2735 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

But The Xamarin Forms one does not crash on the same emulator (and indeed, successfully produces the output I expect)

12-11 13:13:05.460 2801 2801 D Mono : DllImport attempting to load: 'libMicrosoft.CognitiveServices.Speech.core.so'.
12-11 13:13:05.460 2801 2801 D Mono : DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.helloworld/files/.override/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:13:05.460 2801 2801 I chatty : uid=10063(com.companyname.helloworld) identical 1 line
12-11 13:13:05.461 2801 2801 D Mono : DllImport error loading library '/storage/emulated/0/Android/data/com.companyname.helloworld/files/.override/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:13:05.461 2801 2801 D Mono : DllImport error loading library '/system/lib/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:13:05.461 2801 2801 I chatty : uid=10063(com.companyname.helloworld) identical 1 line
12-11 13:13:05.461 2801 2801 D Mono : DllImport error loading library '/system/lib/libMicrosoft.CognitiveServices.Speech.core.so': '(null)'.
12-11 13:13:05.552 2801 2801 D Mono : DllImport loaded library 'libMicrosoft.CognitiveServices.Speech.core.so'.
12-11 13:13:05.552 2801 2801 D Mono : DllImport searching in: 'libMicrosoft.CognitiveServices.Speech.core.so' ('libMicrosoft.CognitiveServices.Speech.core.so').
12-11 13:13:05.552 2801 2801 D Mono : Searching for 'speech_config_from_subscription'.
12-11 13:13:05.552 2801 2801 D Mono : Probing 'speech_config_from_subscription'.
12-11 13:13:05.552 2801 2801 D Mono : Found as 'speech_config_from_subscription'.
12-11 13:13:06.354 2801 2801 D Mono : DllImport searching in: 'libMicrosoft.CognitiveServices.Speech.core.so' ('libMicrosoft.CognitiveServices.Speech.core.so').
12-11 13:13:06.354 2801 2801 D Mono : Searching for 'speech_config_get_property_bag'.
12-11 13:13:06.354 2801 2801 D Mono : Probing 'speech_config_get_property_bag'.
12-11 13:13:06.354 2801 2801 D Mono : Found as 'speech_config_get_property_bag'.
12-11 13:13:06.359 2801 2801 D Mono : DllImport searching in: 'libMicrosoft.CognitiveServices.Speech.core.so' ('libMicrosoft.CognitiveServices.Speech.core.so').
12-11 13:13:06.359 2801 2801 D Mono : Searching for 'property_bag_set_string'.
12-11 13:13:06.359 2801 2801 D Mono : Probing 'property_bag_set_string'.
12-11 13:13:06.359 2801 2801 D Mono : Found as 'property_bag_set_string'.

in case that helps ...

@jhakulin
Copy link
Author

Any updates on this ?

@BrzVlad
Copy link
Member

BrzVlad commented Jan 23, 2020

@jhakulin This issue is caused by stack misalignment, caused most likely by incorrect code generated by the mono runtime. Haven't been able to find the root source of the misalignment today, but I'll figure it out next week.

@BrzVlad
Copy link
Member

BrzVlad commented Jan 28, 2020

This does not look like mono issue. All pinvokes in the Microsoft.CognitiveServices.Speech.csharp.dll are marked as stdcall while the native code from libMicrosoft.CognitiveServices.Speech.core.so appears to be cdecl. This incosistency in the call convention causes the stack misalignment. The first call that misalignes the stack is speech_config_get_property_bag

@BrzVlad BrzVlad closed this as completed Jan 28, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jun 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: Mono Runtime Mono-related issues: BCL bugs, AOT issues, etc.
Projects
None yet
Development

No branches or pull requests

8 participants