Bug 7793 - App crashes immediately with CGImageDestination
Summary: App crashes immediately with CGImageDestination
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2012-10-11 07:16 UTC by tome
Modified: 2012-10-11 09:55 UTC (History)
2 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 tome 2012-10-11 07:16:22 UTC
The problem is that an app crashes when calling CGImageDestination.FromData (and also FromUrl) with specifying some wrong UTI.
That crash raises no exception. I could only know from messages in device organizer console output.

Oct 11 19:58:49 unknown CloudPasteboard[39341] <Error>: ImageIO: _CGImageDestinationCreateWithWriter type doesn't support writing
Oct 11 19:58:50 unknown ReportCrash[39355] <Notice>: Formulating crash report for process CoudPasteboard[39341]
Oct 11 19:58:50 unknown librariand[39346] <Error>: client connection is invalid: Connection invalid
Oct 11 19:58:50 unknown librariand[39346] <Error>: item update observer error: Connection invalid
Oct 11 19:58:50 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:net.tomesoft.CloudPasteboard[0x41d2]) Job appears to have crashed: Trace/BPT trap: 5
Oct 11 19:58:50 unknown SpringBoard[39300] <Warning>: Application 'CloudPasteboard' exited abnormally with signal 5: Trace/BPT trap: 5

Please check following code.

void CrashAppImmediatelyWithCGImageDestination ()
  //string uti ="public.jpeg"; // correct
  string uti = "public.Jpeg"; // wrong 'J' is an upper letter
  NSMutableData destData = new NSMutableData ();
  var dest = CGImageDestination.FromData (destData, uti, 1); // crashes here without raising any exception
  bool success = dest.Close ();

Comment 1 Sebastien Pouliot 2012-10-11 08:50:35 UTC
Stack trace (from device's crash log)

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   CoreFoundation                	0x3a331d24 CFRetain + 8
1   monotouchtest                 	0x0055e25c wrapper_managed_to_native_MonoTouch_CoreFoundation_CFObject_CFRetain_intptr + 56
2   monotouchtest                 	0x00503784 MonoTouch_ImageIO_CGImageDestination__ctor_intptr (CGImageDestination.cs:74)
3   monotouchtest                 	0x00503a50 MonoTouch_ImageIO_CGImageDestination_FromData_MonoTouch_Foundation_NSData_string_int_MonoTouch_ImageIO_CGImageDestinationOptions (CGImageDestination.cs:139)
4   monotouchtest                 	0x00503938 MonoTouch_ImageIO_CGImageDestination_FromData_MonoTouch_Foundation_NSData_string_int (CGImageDestination.cs:106)
Comment 2 Sebastien Pouliot 2012-10-11 09:13:44 UTC
CGImageDestinationCreateWithData returns null and we try to retain it
Comment 3 Sebastien Pouliot 2012-10-11 09:55:57 UTC
Thanks for the test case!

ios6: ce6aa0b1bcce992096671aec86967ccb95bc6d0b
master: 9dfdc5b9abc36c72b79cf528cd1f7a8cad8b2998
QA: unit tests added in both branches