Bug 24693 - SIGSEGV on AssetManager.Open
Summary: SIGSEGV on AssetManager.Open
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.18.1
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-11-20 08:58 UTC by SWC
Modified: 2017-08-08 17:14 UTC (History)
3 users (show)

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


Attachments
Sample Application (15.12 KB, application/zip)
2014-11-24 13:36 UTC, Ram Chandra
Details
AndroidTools.log (10.99 KB, application/octet-stream)
2014-11-24 18:45 UTC, SWC
Details
Test Project (6.95 MB, application/octet-stream)
2014-11-24 18:47 UTC, SWC
Details


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:
Status:
RESOLVED INVALID

Description SWC 2014-11-20 08:58:04 UTC
Opening files with AssetManager.Open for a multiple times crashes my app.

This happens when you call AssetManager.Open for a multiple times. (more than 500 times, afaik)
You get a neat SIGSEGV :)
Comment 1 Prashant manu 2014-11-24 00:37:43 UTC
Could you please provide us the test steps you followed. If possible please
attach a small complete project that demonstrates this behavior.

Also can you please add the logs from the following places?:
On XS IDE Log  Location: XS>Help> Open Log Directory> IDE.log file (with latest
timestamp)
AndroidTools log: XS->Help->Open Log Directory->AndroidTools.log

If using VS, 
IDE log: Location: C:\User\AppData\Local\Xamarin\Log\ 
(Devenev file with latest timestamp)
Android Trace log: Location: \AppData\Local\Xamarin\Log\XamarinAndroid
Comment 2 Ram Chandra 2014-11-24 13:36:49 UTC
Created attachment 8850 [details]
Sample Application

I have checked this issue but I am unable to reproduce this issue.

Steps I followed:

1. Create an Android Application
2. Add an text file in "Asset" directory.
3. Add following text in txt file.

     "I came from an asset!"

4. Write the following code  in "OnCreate" method and read the text from the text file.

        var tv = new TextView(this);
        // Read the contents of our asset
         StringBuilder content = new StringBuilder();
         for (int i = 0; i < 1000; i++)
         {              
           using (StreamReader sr = new StreamReader(Assets.Open("read_asset.txt")))
             {
                    content.Append(sr.ReadToEnd()+"\n");
              }          
            }
            // Set TextView.Text to our asset content
            tv.Text = content.ToString() + "\n";
            SetContentView(tv);


Here I am calling the "Assets.Open("file_name")" 1000 times and I observed that my application is working fine. 

Could you please provide logs and sample application? So, that we can reproduce this issue at our end.

You can get logs form here:

On XS IDE Log  Location: XS>Help> Open Log Directory> IDE.log file (with latest timestamp)
AndroidTools log: XS->Help->Open Log Directory->AndroidTools.log

If using VS, 
IDE log: Location: C:\User\AppData\Local\Xamarin\Log\ 
(Devenev file with latest timestamp)
Android Trace log: Location: \AppData\Local\Xamarin\Log\XamarinAndroid

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.50938
Installed Version: Professional
Xamarin   3.8.150.0 (10cfd178d55287f09c85f5a1e604dfe20889a40f)
Xamarin.Android   4.20.0.28 (ba9bbbdd44cfdc4bf485e8885bd2ad24fba525f7)
Xamarin.iOS   8.4.0.0 (840a925103a0bf4a856507f13d5eaee3c1579c2f)
Comment 3 SWC 2014-11-24 18:45:30 UTC
Created attachment 8855 [details]
AndroidTools.log
Comment 4 SWC 2014-11-24 18:47:14 UTC
Created attachment 8856 [details]
Test Project
Comment 5 SWC 2014-11-24 18:47:39 UTC
On this, I get this SIGSEGV:

[mono-rt] Stacktrace:
[mono-rt] 
[mono-rt]   at <unknown> <0xffffffff>
[mono-rt]   at (wrapper managed-to-native) object.wrapper_native_0x40877ed9 (intptr,intptr,intptr,Android.Runtime.JValue[]) <IL 0x00127, 0xffffffff>
[mono-rt]   at (wrapper delegate-invoke) <Module>.invoke_intptr_intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,Android.Runtime.JValue[]) <IL 0x00063, 0xffffffff>
[mono-rt]   at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00040] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/4f8f6db2/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:191
[mono-rt]   at Android.Content.Res.AssetManager.Open (string) [0x00034] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/4f8f6db2/source/monodroid/src/Mono.Android/platforms/android-14/src/generated/Android.Content.Res.AssetManager.cs:74
[mono-rt]   at test.MainActivity/<>c__DisplayClass1.<OnCreate>b__0 (object,System.EventArgs) [0x00007] in c:\Users\SWC\Documents\Projects\test\test\MainActivity.cs:32
[mono-rt]   at Android.Views.View/IOnClickListenerImplementor.OnClick (Android.Views.View) [0x0000d] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/4f8f6db2/source/monodroid/src/Mono.Android/platforms/android-14/src/generated/Android.Views.View.cs:1615
[mono-rt]   at Android.Views.View/IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/4f8f6db2/source/monodroid/src/Mono.Android/platforms/android-14/src/generated/Android.Views.View.cs:1582
[mono-rt]   at (wrapper dynamic-method) object.5f4f6e0c-56a6-4b20-9dfa-d71aa981a9d8 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
[mono-rt]   at (wrapper native-to-managed) object.5f4f6e0c-56a6-4b20-9dfa-d71aa981a9d8 (intptr,intptr,intptr) <IL 0x00023, 0xffffffff>
[mono-rt] 
[mono-rt] =================================================================
[mono-rt] Got a SIGSEGV while executing native code. This usually indicates
[mono-rt] a fatal error in the mono runtime or one of the native libraries 
[mono-rt] used by your application.
[mono-rt] =================================================================
[mono-rt] 
[libc] Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 21481 (test.test)
Comment 6 Jon Douglas [MSFT] 2017-08-08 17:14:39 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.