Bug 6992 - Subclass of ObjectiveC object crashes if binding project referenced in library project but not executable project
Summary: Subclass of ObjectiveC object crashes if binding project referenced in librar...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.2
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-07 11:41 UTC by Jonathan
Modified: 2012-09-11 18:36 UTC (History)
2 users (show)

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


Attachments
Example project demonstrating the issue (552.62 KB, application/zip)
2012-09-07 11:41 UTC, Jonathan
Details
Prevents the GC exception from earlier project (553.31 KB, application/zip)
2012-09-11 10:38 UTC, Jonathan
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 FIXED

Description Jonathan 2012-09-07 11:41:56 UTC
Created attachment 2478 [details]
Example project demonstrating the issue

I have a binding project that binds an Objective-C library, a MonoTouch library project, and a MonoTouch application project.  Inside of my MonoTouch library, I have a reference to the binding project and a subclass of a native object that is defined in the Objective-C library.

If I do not have a reference to the binding project in my application project, the application will crash whenever I call the subclass's constructor.  It will not crash, however, if I call a method inside of the library that constructs the native object instead of the subclass.  Why would it only crash for the subclass?

I have attached an example demonstrating this problem.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-09-11 06:22:12 UTC
Do you get an exception or is it a crash? Can you add the exception message/stack trace or the crash report to the bug?

I get this exception even if I reference StackedView directly from the main app: "Selector invoked from objective-c on a managed object of type TestLib.StackedController (0xE660760) that has been GC'ed," so maybe it's not what you're seeing.
Comment 2 Jonathan 2012-09-11 10:38:04 UTC
Created attachment 2501 [details]
Prevents the GC exception from earlier project
Comment 3 Jonathan 2012-09-11 10:39:00 UTC
Sorry about that.  I've uploaded a new project that prevents the GC exception.  The crash that I'm getting throws no exception, just a SIGSEGV with a stack trace.  Here it is:

Stacktrace:

  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper (intptr,intptr) <IL 0x00026, 0xffffffff>
  at StackedView.PSStackedViewController..ctor () [0x0004c] in /Users/Jonathan/Projects/Test/StackedView/obj/Debug/ios/StackedView/PSStackedViewController.g.cs:113
  at TestLib.StackedController..ctor () <IL 0x00001, 0x00023>
  at Test.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication,MonoTouch.Foundation.NSDictionary) [0x0002d] in /Users/Jonathan/Projects/Test/Test/AppDelegate.cs:33
  at (wrapper runtime-invoke) <Module>.runtime_invoke_bool__this___object_object (object,intptr,intptr,intptr) <IL 0x00066, 0xffffffff>
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  at Test.Application.Main (string[]) [0x00000] in /Users/Jonathan/Projects/Test/Test/Main.cs:17
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   Test                                0x0009061c mono_handle_native_sigsegv + 284
	1   Test                                0x000059a8 mono_sigsegv_signal_handler + 248
	2   libsystem_c.dylib                   0x94a8f59b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   ???                                 0x0dfef418 0x0 + 234812440
	5   ???                                 0x0dfef28c 0x0 + 234812044
	6   ???                                 0x0dfea94c 0x0 + 234793292
	7   ???                                 0x0dfeab5d 0x0 + 234793821
	8   Test                                0x00009d12 mono_jit_runtime_invoke + 722
	9   Test                                0x00169e4e mono_runtime_invoke + 126
	10  Test                                0x002065c8 monotouch_trampoline + 3416
	11  UIKit                               0x02256386 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1292
	12  UIKit                               0x02257274 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 524
	13  UIKit                               0x02266183 -[UIApplication handleEvent:withNewEvent:] + 1027
	14  UIKit                               0x02266c38 -[UIApplication sendEvent:] + 68
	15  UIKit                               0x0225a634 _UIApplicationHandleEvent + 8196
	16  GraphicsServices                    0x047c5ef5 PurpleEventCallback + 1274
	17  CoreFoundation                      0x011a9195 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
	18  CoreFoundation                      0x0110dff2 __CFRunLoopDoSource1 + 146
	19  CoreFoundation                      0x0110c8da __CFRunLoopRun + 2218
	20  CoreFoundation                      0x0110bd84 CFRunLoopRunSpecific + 212
	21  CoreFoundation                      0x0110bc9b CFRunLoopRunInMode + 123
	22  UIKit                               0x02256c65 -[UIApplication _run] + 576
	23  UIKit                               0x02258626 UIApplicationMain + 1163
	24  ???                                 0x0dfe5a05 0x0 + 234772997
	25  ???                                 0x0dcf1f18 0x0 + 231677720
	26  ???                                 0x0dcf1c10 0x0 + 231676944
	27  ???                                 0x0dcf1d66 0x0 + 231677286
	28  Test                                0x00009d12 mono_jit_runtime_invoke + 722
	29  Test                                0x00169e4e mono_runtime_invoke + 126
	30  Test                                0x0016df34 mono_runtime_exec_main + 420
	31  Test                                0x001732e5 mono_runtime_run_main + 725
	32  Test                                0x00066f15 mono_jit_exec + 149
	33  Test                                0x002115d5 main + 2837
	34  Test                                0x00002d65 start + 53

=================================================================
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.
=================================================================
Comment 4 Rolf Bjarne Kvinge [MSFT] 2012-09-11 17:55:56 UTC
I can't reproduce this crash, neither in the simulator nor on device.

* Which versions of Xcode, MonoDevelop and MonoTouch are you using?
* Does the same thing happen on both the simaultor and on a device?
Comment 5 Jonathan 2012-09-11 18:31:55 UTC
Well, I was using MonoTouch 5.2.13, but I tried updating to 5.4 and I'm no longer seeing the crash.  Problem solved, I guess.  Thanks anyway!
Comment 6 Rolf Bjarne Kvinge [MSFT] 2012-09-11 18:36:00 UTC
Great, closing this then :)