Bug 12224 - CFString Dispose random crash
Summary: CFString Dispose random crash
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-05-13 14:40 UTC by Brian Lee
Modified: 2013-12-05 18:34 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED NORESPONSE

Description Brian Lee 2013-05-13 14:40:10 UTC
I'm filing a bug report for the link.
http://stackoverflow.com/questions/16364943/cfstring-dispose-random-crash

I am trying to create a thumbnail image of pdf in Monotouch but the app crashes SOMETIMES and throws below error.


Stacktrace:

  at MonoTouch.CoreFoundation.CFString.Dispose () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFString.cs:131
  at MonoTouch.CoreFoundation.CFUrl.FromFile (string) [0x00048] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFUrl.cs:79
  at MonoTouch.CoreGraphics.CGPDFDocument.FromFile (string) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreGraphics/CGPDFDocument.cs:98
  at eBriefing.BookmarkView/<BookmarkView>c__AnonStorey15.<>m__51 (object,System.ComponentModel.DoWorkEventArgs) [0x0003d] in /Users/jlee/Desktop/TFS2010/eBriefing/iPad App/Mobile/Main/eBriefing/eBriefing/SourceCodes/Bookmark/BookmarkView.cs:48
  at System.ComponentModel.BackgroundWorker.OnDoWork (System.ComponentModel.DoWorkEventArgs) [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.ComponentModel/BackgroundWorker.cs:174
  at System.ComponentModel.BackgroundWorker.ProcessWorker (object,System.ComponentModel.AsyncOperation,System.Threading.SendOrPostCallback) [0x00009] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.ComponentModel/BackgroundWorker.cs:129
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object_object (object,intptr,intptr,intptr) <IL 0x00064, 0xffffffff>

Native stacktrace:

	0   eBriefing                           0x00276b1c mono_handle_native_sigsegv + 284
	1   eBriefing                           0x001ea3f8 mono_sigsegv_signal_handler + 248
	2   libsystem_c.dylib                   0x94a2f8cb _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   eBriefing                           0x002cbfd1 mono_class_from_name + 49
	5   eBriefing                           0x003447dc mono_mb_emit_exception_full + 44
	6   eBriefing                           0x0034494f mono_mb_emit_exception + 47
	7   eBriefing                           0x00320c66 mono_marshal_get_native_wrapper + 870
	8   eBriefing                           0x0021348d mono_method_to_ir + 44253
	9   eBriefing                           0x001f0848 mini_method_compile + 1144
	10  eBriefing                           0x001f2c66 mono_jit_compile_method_with_opt + 1270
	11  eBriefing                           0x001ee499 mono_jit_compile_method + 41
	12  eBriefing                           0x0027a2f1 common_call_trampoline + 1041
	13  eBriefing                           0x002781aa mono_vcall_trampoline + 202
	14  ???                                 0x0c096c74 0x0 + 201944180
	15  ???                                 0x1602c5ac 0x0 + 369280428
	16  ???                                 0x1602be8c 0x0 + 369278604
	17  ???                                 0x1602bcc0 0x0 + 369278144
	18  ???                                 0x14a46af6 0x0 + 346319606
	19  ???                                 0x14a46005 0x0 + 346316805
	20  ???                                 0x14a45b03 0x0 + 346315523
	21  eBriefing                           0x001ee7c2 mono_jit_runtime_invoke + 722
	22  eBriefing                           0x00351c9e mono_runtime_invoke + 126
	23  eBriefing                           0x00358558 mono_runtime_invoke_array + 1544
	24  eBriefing                           0x00358a2f mono_message_invoke + 479
	25  eBriefing                           0x00386f6d async_invoke_thread + 1997
	26  eBriefing                           0x0038cce6 start_wrapper + 422
	27  eBriefing                           0x003becaa thread_start_routine + 154
	28  eBriefing                           0x003e61ad GC_start_routine + 93
	29  libsystem_c.dylib                   0x94a435b7 _pthread_start + 344
	30  libsystem_c.dylib                   0x94a2dd4e thread_start + 34

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


Application Terminated


And below is the code.
If you look at the crash it crashes at CGPDFDocument.FromFile(url); whereCGPDFDocument.FromFile references CFUrl and CFUrl references CFString. The weird thing is that it does not crash all the time and it is hard to reproduce.
It crashes on both the simulator and the device (running iOS 6)

                    if (!String.IsNullOrEmpty(url))
                    {
                        UIImage image = null;
                        BackgroundWorker worker = new BackgroundWorker();
                        worker.DoWork += delegate
                        {
                            CGPDFDocument pdfDoc = CGPDFDocument.FromFile(url);
                            if (pdfDoc != null)
                            {
                                CGPDFPage pdfPage = pdfDoc.GetPage(1);
                                image = PDFConverter.TransformToImage(pdfPage, 150);
                            }
                        };
                        worker.RunWorkerCompleted += delegate
                        {
                            this.InvokeOnMainThread(delegate
                            {
                                cell.Image = image;
                            });
                        };
                        worker.RunWorkerAsync();
                    }
Comment 1 Miguel de Icaza [MSFT] 2013-05-13 17:56:48 UTC
I tried reproducing the bug, but was not able to.

Perhaps early memory corruption?

Could you please share the full test case?
Comment 2 Sebastien Pouliot 2013-05-13 20:16:12 UTC
Other (in addition to a full test case) helpful things would be:

* The values of `url` (e.g. encoding issues);

* A symbolicated crash report. The stacktrace above does not show what the other threads are currently doing (but a crash report would list them);

* Knowing if this also occurs on devices (or just on the simulator);

* The full versions of the software you're using [1]



[1] The easiest way to get exact version information is to use the "Xamarin Studio" menu, "About Xamarin Studio" item, "Show Details" button and copy/paste the version informations (you can use the "Copy Information" button).
Comment 3 PJ 2013-11-19 17:04:38 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 4 PJ 2013-12-05 18:34:47 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.