Bug 13707 - SIGSEGV while executing native code (Android.Net.UriInvoker)
Summary: SIGSEGV while executing native code (Android.Net.UriInvoker)
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.8.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-08-02 07:16 UTC by Goncalo Oliveira
Modified: 2017-06-27 15:44 UTC (History)
4 users (show)

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

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 Goncalo Oliveira 2013-08-02 07:16:00 UTC
I'm getting a SIGSEGV exception with the new 4.6.8 stable release. Unlike bug 13521 this is not related to a library binding.

I have this activity with a custom adapter (based on BaseAdapter). When overriding getView, I'm setting a thumbnail bitmap to an ImageView using the following code

                    icon.SetImageBitmap( MediaStore.Images.Thumbnails.GetThumbnail(Context.ContentResolver,
                        long.Parse( item.MediaLocation.LastPathSegment ),
                        ThumbnailKind.MicroKind, (BitmapFactory.Options)null ) );

icon is an instance of ImageView
item is an instance of a local class - PictureInfo (described below)
item.MediaLocation is an instance of Android.Net.Uri

This has worked well so far and continues to do well with previous stable 4.6.0.
I'll try attach a test case as soon as possible.

The PictureInfo class

    public class PictureInfo
        public string Name { get; set; }

        public string Description { get; set; }

        public Android.Net.Uri MediaLocation { get; set; }

08-01 11:13:08.990: E/mono-rt(3015): Stacktrace:
08-01 11:13:08.990: E/mono-rt(3015):   at <unknown> <0xffffffff>
08-01 11:13:08.990: E/mono-rt(3015):   at (wrapper managed-to-native)
object.wrapper_native_0xaca44f59 (intptr,intptr,intptr) <IL 0x00027,
08-01 11:13:08.990: E/mono-rt(3015):   at
Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr) [0x00005] in
08-01 11:13:08.990: E/mono-rt(3015):   at Android.Net.UriInvoker.ToString ()
[0x0002d] in
08-01 11:13:08.990: E/mono-rt(3015):   at (wrapper runtime-invoke)
<Module>.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <IL
0x00050, 0xffffffff>
08-01 11:13:08.990: E/mono-rt(3015):   at <unknown> <0xffffffff>
08-01 11:13:08.990: E/mono-rt(3015):   at
[0x00025] in
08-01 11:13:08.990: E/mono-rt(3015):   at
(int,Android.Views.View,Android.Views.ViewGroup) [0x0002f] in
08-01 11:13:08.990: E/mono-rt(3015):   at
(intptr,intptr,int,intptr,intptr) [0x00019] in
08-01 11:13:08.990: E/mono-rt(3015):   at (wrapper dynamic-method)
object.b4dd859c-5c27-4cba-8d08-56fdf0af81a6 (intptr,intptr,int,intptr,intptr)
<IL 0x00023, 0x0005f>
08-01 11:13:08.990: E/mono-rt(3015):   at (wrapper native-to-managed)
object.b4dd859c-5c27-4cba-8d08-56fdf0af81a6 (intptr,intptr,int,intptr,intptr)
<IL 0x00028, 0xffffffff>
08-01 11:13:08.990: E/mono-rt(3015):
08-01 11:13:08.990: E/mono-rt(3015): Got a SIGSEGV while executing native code.
This usually indicates
08-01 11:13:08.990: E/mono-rt(3015): a fatal error in the mono runtime or one
of the native libraries 
08-01 11:13:08.990: E/mono-rt(3015): used by your application.
08-01 11:13:08.990: E/mono-rt(3015):
Comment 1 earchambault 2013-09-26 17:21:02 UTC
I am having a similar issue to this one as well.
Comment 2 Jonathan Pryor 2013-09-26 17:42:02 UTC
Need a test case.


> E/mono-rt(3015): Stacktrace:
> E/mono-rt(3015):   at <unknown> <0xffffffff>
> E/mono-rt(3015):   at (wrapper managed-to-native) object.wrapper_native_0xaca44f59 (intptr,intptr,intptr)
> E/mono-rt(3015):   at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr)

(or any other JNIEnv.Call*Method() in the call stack)

frequently happens because the Java.Lang.Object.Handle property is returning IntPtr.Zero, and thus we're invoking a method on a `null` Java object. (The C# side has a non-null object; it's the corresponding Java instance which doesn't exist.)

This can in turn happen for a variety of reasons, from a premature Dispose() call, to a GC bug, to Dispose()ing a "temporary" that is in fact shared "elsewhere".
Comment 3 Chris Hardy [MSFT] 2017-06-27 15:44:54 UTC
Unfortunately, we’re unable to reproduce this report. If this issue is still occurring for you, please reopen this issue and attach a reproduction to the bug by starting with a clean Xamarin.Android project adding just the code necessary to demonstrate the issue.