Bug 18215 - Got SIGSEGV on Android 4.3 when working with KeyStore API
Summary: Got SIGSEGV on Android 4.3 when working with KeyStore API
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.10.0.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-03-06 08:58 UTC by Paul
Modified: 2017-06-27 00:18 UTC (History)
4 users (show)

Tags: bb
Is this bug a regression?: ---
Last known good build:

Logcat (7.66 KB, text/plain)
2014-03-06 08:58 UTC, Paul
Demo project (also available on github, see the bug description) (178.11 KB, application/zip)
2014-03-06 09:04 UTC, Paul
Jar if you are not to wish to build it (12.53 KB, application/octet-stream)
2014-03-11 06:40 UTC, Paul
Demo proj with NuGet packages (1.13 MB, application/zip)
2014-04-24 11:44 UTC, Paul

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Paul 2014-03-06 08:58:36 UTC
Created attachment 6243 [details]

Sometimes my Android application which is used KeyStore API is crashed. Crashes occurs often and unpredictable but they occurs on Android 4.3 not on Android 2.3.7 (at least I'm unable to reproduce them on 2.3.7). The code I'm trying to use was taken from Xamarin github repo (https://github.com/xamarin/Xamarin.Auth). It looks like all KeyStore related code works fine but when app switched to "some UI code" something goes wrong and app crashed with

03-06 13:04:23.814 E/mono-rt ( 1619): =================================================================
03-06 13:04:23.814 E/mono-rt ( 1619): Got a SIGSEGV while executing native code. This usually indicates
03-06 13:04:23.814 E/mono-rt ( 1619): a fatal error in the mono runtime or one of the native libraries 
03-06 13:04:23.814 E/mono-rt ( 1619): used by your application.
03-06 13:04:23.814 E/mono-rt ( 1619): =================================================================

but without any stacktrace. I have been attached some code but you can check the repo: https://github.com/Paul-N/KeyStoreBug
Comment 1 Paul 2014-03-06 09:01:19 UTC
If bug doesn't appears press "Run tests" button multiple times.
Comment 2 Paul 2014-03-06 09:04:55 UTC
Created attachment 6244 [details]
Demo project (also available on github, see the bug description)
Comment 3 Paul 2014-03-06 09:07:29 UTC
I'm using Xamarin.Android 4.10.01073, but it is possible to reproduce this bug on 4.12
Comment 4 Sadik Ali 2014-03-11 03:32:42 UTC
I have tried to check this issue on below environments:

XS 4.2.3(Build 60)
XA 4.12.1
Android 4.3.0 API 18

I followed below steps

1. Downloaded code from git "http://screencast.com/t/KvPODGPfuj2"
2. Debug application multiple times successfully on Android 4.3.0 API 18.
3. I am unable to reproduce issue.

Refer screen cast: http://screencast.com/t/KvPODGPfuj2

Also I have tried with attached project, Added required assemblies.
When I build application getting error for the "AndroidAuthNative_jar.jar"

 C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(5,5): Error: Specified source jar not found: ..\..\AndroiAuthNative\AndroidAuthNative\out\artifacts\AndroiAuthNative_jar\AndroidAuthNative_jar.jar (Xamarin.Auth.Droid(Jar exported))

Refer screen shot: http://screencast.com/t/7d1b3dNbU 
To created jar file, I tried to build project "AndroidAuthNative" using ant  build tool but not success.

Please let me know how to generate jar file.
Comment 5 Paul 2014-03-11 06:34:01 UTC
Sadik Ali, thanks for your attention.

1. It's enough to run only AndroidAuth.MvvmCross/Xamarin.Auth.Droid.Tests(unmodified) to check this bug. This project is uses original Xamarin.Auth library which is copied to project tree.

2. In order to build AndroidAuthNative_jar.jar you should first open Android Java project which is located in KeyStoreBug / AndroiAuthNative and build jar artifact (with the help of IDEA for example). I'll attach this jar soon here, so you can just change link to this one.

3. You have been unable to repro this bug because you run this code just once in every app launch. This bug sometime occurred and some times not. To increase probability you should run it in cycle (like I do in my tests).
Comment 6 Paul 2014-03-11 06:40:53 UTC
Created attachment 6283 [details]
Jar if you are not to wish to build it
Comment 7 Sadik Ali 2014-03-11 10:52:47 UTC
I have checked this issue with adding attached jar file to project.

I debug application "AndroidAuth.MvvmCross/Xamarin.Auth.Droid.Tests(unmodified)" and noticed that only some time application get hanged (not responding ) when I click on "Run Test" 
Refer screen cast: http://screencast.com/t/hkRLgozVfcp

Can you please provide some screen cast so that I can check this issue.

Also I tried to check with other project (Xamarin.Auth.Droid.Tests(jar tests), Xamarin.Auth.Droid.Tests) but not able to reproduce.
Comment 8 Paul 2014-03-11 11:34:06 UTC
It's not responding because I'm executing test code on main thread in loop of 500 iteration to increase probability that bug will occurred. But sometimes even 500 times is not enough. When I preparing screencast, I have had execute test 2 times.
Here this screencast: http://youtu.be/XghZ2LTEps4
Comment 9 Paul 2014-03-11 11:36:11 UTC
Some additional info: I use Genymotion 2.1.1 with emulator Galaxy Nexus 4.3 API 18 720x1280.
Comment 10 Jonathan Pryor 2014-04-23 15:16:21 UTC
I am unable to build either the git project or Attachment #6244 [details]:

> KeyStoreBug/AndroidAuth.MvvmCross/Xamarin.Auth/PluginLoader.cs(7,7):
> Error CS0246: The type or namespace name `Cirrious' could not be found.
> Are you missing an assembly reference? (CS0246) (Xamarin.Auth)

Please provide a self-contained (i.e. contains all dependencies), _building_, project.
Comment 11 Paul 2014-04-24 11:44:20 UTC
Created attachment 6650 [details]
Demo proj with NuGet packages

 Jonathan Pryor, that was NuGet dependencies. I've been upload demo project that includs it once again.
Comment 12 Jonathan Pryor 2014-04-24 16:04:35 UTC
@Paul: Thank you for Attachment #6650 [details], it now builds and installs for me.

What target device are you running this on (hardware, emulator)? Have you tried Android v4.4?

Is this a Debug or a Release build? The lack of [Mono] messages in Attachment #6243 [details] suggests that this is a Release app, or the app was built prior to Xamarin.Android 4.10, which changed the default Debug log level:


I haven't been able to see the crash in either Debug or Release builds when using Xamarin.Android 4.12.3 on a Nexus 5 running Android v4.4.2.

> It looks like all KeyStore related code works fine but when app 
> switched to "some UI code" something goes wrong and app crashed

I don't understand what this means, or what part of the code this would be in.
Comment 13 Chris Hardy [MSFT] 2017-06-26 17:41:44 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!