Bug 95 - [Export("initWithFrame:")] breaks when trying to extend a NSView class
Summary: [Export("initWithFrame:")] breaks when trying to extend a NSView class
Status: RESOLVED INVALID
Alias: None
Product: MonoMac
Classification: Desktop
Component: Bindings ()
Version: unspecified
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Miguel de Icaza [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2011-07-27 19:10 UTC by Phi
Modified: 2012-03-12 22:44 UTC (History)
2 users (show)

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


Attachments
In sample project, uncomment MainWindowController.cs:33 to get error (27.63 KB, application/zip)
2011-07-27 19:10 UTC, Phi
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 Phi 2011-07-27 19:10:10 UTC
Created attachment 27 [details]
In sample project, uncomment MainWindowController.cs:33 to get error

In sample project, uncomment MainWindowController.cs:33 to get error
Comment 1 Phi 2011-08-05 18:15:51 UTC
Error output:
Stacktrace:

  at (wrapper managed-to-native) MonoMac.ObjCRuntime.Messaging.void_objc_msgSendSuper_bool (intptr,intptr,bool) <IL 0x0002d, 0xffffffff>
  at MonoMac.AppKit.NSSplitView.set_IsVertical (bool) [0x00021] in /cvs/monomac/src/AppKit/NSSplitView.g.cs:196
  at SplitViewTest.MainWindowController.Initialize () [0x00006] in /Users/phi/Downloads/SplitViewTest/SplitViewTest/MainWindowController.cs:54
  at SplitViewTest.MainWindowController..ctor () [0x0000b] in /Users/phi/Downloads/SplitViewTest/SplitViewTest/MainWindowController.cs:25
  at SplitViewTest.AppDelegate.FinishedLaunching (MonoMac.Foundation.NSObject) [0x00000] in /Users/phi/Downloads/SplitViewTest/SplitViewTest/AppDelegate.cs:19
  at (wrapper dynamic-method) object.[SplitViewTest.AppDelegate.Void FinishedLaunching(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x00011, 0x00050>
  at (wrapper native-to-managed) object.[SplitViewTest.AppDelegate.Void FinishedLaunching(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <IL 0x000b6, 0xffffffff>
  at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <IL 0x0009d, 0xffffffff>
  at MonoMac.AppKit.NSApplication.Main (string[]) [0x00000] in /cvs/monomac/src/AppKit/NSApplication.cs:74
  at SplitViewTest.MainClass.Main (string[]) [0x00005] in /Users/phi/Downloads/SplitViewTest/SplitViewTest/Main.cs:14
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   SplitViewTest                       0x000b6ea9 0x0 + 749225
	1   SplitViewTest                       0x00006e0e 0x0 + 28174
	2   libSystem.B.dylib                   0x94fc145b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   ???                                 0x054ce5d2 0x0 + 88925650
	5   ???                                 0x054ce4fa 0x0 + 88925434
	6   ???                                 0x054cc26d 0x0 + 88916589
	7   ???                                 0x02e0eb9a 0x0 + 48294810
	8   ???                                 0x02e0eaee 0x0 + 48294638
	9   ???                                 0x02df1f91 0x0 + 48177041
	10  ???                                 0x02e0b25c 0x0 + 48280156
	11  Foundation                          0x91bf73bf _nsnote_callback + 176
	12  CoreFoundation                      0x978cb793 __CFXNotificationPost + 947
	13  CoreFoundation                      0x978cb19a _CFXNotificationPostNotification + 186
	14  Foundation                          0x91bec25c -[NSNotificationCenter postNotificationName:object:userInfo:] + 128
	15  Foundation                          0x91bf9669 -[NSNotificationCenter postNotificationName:object:] + 56
	16  AppKit                              0x96c8a422 -[NSApplication _postDidFinishNotification] + 125
	17  AppKit                              0x96c8a332 -[NSApplication _sendFinishLaunchingNotification] + 74
	18  AppKit                              0x96de14ed -[NSApplication(NSAppleEventHandling) _handleAEOpen:] + 274
	19  AppKit                              0x96de110d -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 101
	20  Foundation                          0x91c2c6c8 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 511
	21  Foundation                          0x91c2c48c _NSAppleEventManagerGenericHandler + 228
	22  AE                                  0x9581af58 _Z20aeDispatchAppleEventPK6AEDescPS_mPh + 166
	23  AE                                  0x9581ae57 _ZL25dispatchEventAndSendReplyPK6AEDescPS_ + 43
	24  AE                                  0x9581ad61 aeProcessAppleEvent + 197
	25  HIToolbox                           0x93919197 AEProcessAppleEvent + 50
	26  AppKit                              0x96c5a9ca _DPSNextEvent + 1420
	27  AppKit                              0x96c59fce -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
	28  AppKit                              0x96c1c247 -[NSApplication run] + 821
	29  AppKit                              0x96c142d9 NSApplicationMain + 574
	30  ???                                 0x02e0b76c 0x0 + 48281452
	31  ???                                 0x02e0b566 0x0 + 48280934
	32  ???                                 0x003d7ff8 0x0 + 4030456
	33  ???                                 0x003d8156 0x0 + 4030806
	34  SplitViewTest                       0x000112c4 0x0 + 70340
	35  SplitViewTest                       0x001bd83c 0x0 + 1824828
	36  SplitViewTest                       0x001bfe35 0x0 + 1834549
	37  SplitViewTest                       0x001bf21f 0x0 + 1831455
	38  SplitViewTest                       0x000884c2 0x0 + 558274
	39  SplitViewTest                       0x00003a46 0x0 + 14918

Debug info from gdb:

/tmp/mono-gdb-commands.rofU0g:1: Error in sourced command file:
unable to debug self

=================================================================
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 2 Phi 2011-08-05 18:18:25 UTC
That output above is displayed in MD 2.6b3

Below is from the CrashReporter.

Process:         mono [23264]
Path:            /Users/phi/Downloads/SplitViewTest/SplitViewTest/bin/Debug/SplitViewTest.app/SplitViewTest
Identifier:      com.yourcompany.SplitViewTest
Version:         0.1 (1)
Code Type:       X86 (Native)
Parent Process:  launchd [110]

Date/Time:       2011-08-05 15:14:31.720 -0700
OS Version:      Mac OS X 10.6.7 (10J869)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000004
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
abort() called

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib             	0x94fbc156 __kill + 10
1   libSystem.B.dylib             	0x94fbc148 kill$UNIX2003 + 32
2   libSystem.B.dylib             	0x9504e899 raise + 26
3   libSystem.B.dylib             	0x950649b8 abort + 93
4   SplitViewTest                 	0x000b70b7 0x1000 + 745655
5   SplitViewTest                 	0x00006e0e 0x1000 + 24078
6   libSystem.B.dylib             	0x94fc145b _sigtramp + 43
7   ???                           	0xbfffde90 0 + 3221216912

Thread 1:
0   libSystem.B.dylib             	0x94f5b0d6 semaphore_wait_trap + 10
1   SplitViewTest                 	0x00244806 0x1000 + 2373638
2   SplitViewTest                 	0x0014add8 0x1000 + 1351128
3   SplitViewTest                 	0x001f983a 0x1000 + 2066490
4   SplitViewTest                 	0x001f98da 0x1000 + 2066650
5   SplitViewTest                 	0x0023796b 0x1000 + 2320747
6   SplitViewTest                 	0x00268e87 0x1000 + 2522759
7   libSystem.B.dylib             	0x94f887fd _pthread_start + 345
8   libSystem.B.dylib             	0x94f88682 thread_start + 34

Thread 2:
0   libSystem.B.dylib             	0x94f985d2 recvfrom$UNIX2003 + 10
1   libSystem.B.dylib             	0x94fb83a7 recv$UNIX2003 + 54
2   SplitViewTest                 	0x000e3ef8 0x1000 + 929528
3   SplitViewTest                 	0x0023796b 0x1000 + 2320747
4   SplitViewTest                 	0x00268e87 0x1000 + 2522759
5   libSystem.B.dylib             	0x94f887fd _pthread_start + 345
6   libSystem.B.dylib             	0x94f88682 thread_start + 34

Thread 3:  Dispatch queue: com.apple.libdispatch-manager
0   libSystem.B.dylib             	0x94f81922 kevent + 10
1   libSystem.B.dylib             	0x94f8203c _dispatch_mgr_invoke + 215
2   libSystem.B.dylib             	0x94f814f9 _dispatch_queue_invoke + 163
3   libSystem.B.dylib             	0x94f8129e _dispatch_worker_thread2 + 240
4   libSystem.B.dylib             	0x94f80d21 _pthread_wqthread + 390
5   libSystem.B.dylib             	0x94f80b66 start_wqthread + 30

Thread 4:
0   libSystem.B.dylib             	0x94f809b2 __workq_kernreturn + 10
1   libSystem.B.dylib             	0x94f80f48 _pthread_wqthread + 941
2   libSystem.B.dylib             	0x94f80b66 start_wqthread + 30

Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0x00000000  ebx: 0x95064967  ecx: 0xbfffd17c  edx: 0x94fbc156
  edi: 0x00005aec  esi: 0xbfffd238  ebp: 0xbfffd198  esp: 0xbfffd17c
   ss: 0x0000001f  efl: 0x00000282  eip: 0x94fbc156   cs: 0x00000007
   ds: 0x0000001f   es: 0x0000001f   fs: 0x00000000   gs: 0x00000037
  cr2: 0xa06be000
Comment 3 Miguel de Icaza [MSFT] 2012-03-12 22:44:50 UTC
This is not really a bug in MonoMac, but one of the areas where the current binding can not enforce as much strong typing as we would like to.

NSViews must be initialized using the RectangleF constructor, so you should do:

class MySplitter : NSSplitView {
    public MySplitter (RectangleF frame) : base (frame) 
    {
    }
}

There is no need to decorate the constructor with an [Export ("initWithFrame:")] attribute, since there is really no runtime code that would ever want to dynamically invoke your constructor with that.

Now, if there was a situation like that (like "initWithCoder" which is a common idiom, or your own in-house Objective-C framework that /mandates/ the use of initWithFrame instead of the standard pattern of using initWithCoder) then you would need the Export attribute.