[Mono-devel-list] Using anonymous delegates with Cocoa-Sharp...

Patrick Beard pcbeard at mac.com
Tue Mar 22 17:06:30 EST 2005


This is apparently fixed in the latest svn sources. The crash was 
happening when using 1.1.4.

- Patrick

On Mar 18, 2005, at 8:46 AM, Patrick Beard wrote:

> I noticed that mcs now supports anonymous delegates, so I tried 
> experimenting in monodoc:
>
> 	delegate void Action();
> 	
> 	[Export("goForward:")]
> 	public void goForward(object sender) {
> 		WebBackForwardList history = webView.backForwardList;
> 		Action a = delegate {
> 			if (history.forwardListCount > 0) {
> 				history.goForward();
> 				loadHistoryItem(history.currentItem);
> 			}
> 		};
> 		a();
> 	}
>
> When the delegate executes, this crashes the process (see stack crawl 
> at end). Presumably it's the access the local variable history that's 
> crashing, because if I change the code to this it doesn't crash:
>
> 	[Export("goForward:")]
> 	public void goForward(object sender) {
> 		Action a = delegate {
> 			WebBackForwardList history = webView.backForwardList;
> 			if (history.forwardListCount > 0) {
> 				history.goForward();
> 				loadHistoryItem(history.currentItem);
> 			}
> 		};
> 		a();
> 	}
>
> Is this feature fully supported or only partially implemented?
>
> - Patrick
>
> Exception:  EXC_BAD_ACCESS (0x0001)
> Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000
>
> Thread 0 Crashed:
> 0   <<00000000>> 	0x05e71464 0 + 0x5e71464
> 1   <<00000000>> 	0x05e718a8 0 + 0x5e718a8
> 2   <<00000000>> 	0x05e71804 0 + 0x5e71804
> 3   <<00000000>> 	0x05e716c0 0 + 0x5e716c0
> 4   <<00000000>> 	0x05e70c38 0 + 0x5e70c38
> 5   mono                     	0x000613a8 mono_runtime_invoke_array + 
> 0x2a4 (object.c:1909)
> 6   mono                     	0x00079788 ves_icall_InternalInvoke + 
> 0x294 (icall.c:2370)
> 7   <<00000000>> 	0x017ae9d8 0 + 0x17ae9d8
> 8   <<00000000>> 	0x017ae1f4 0 + 0x17ae1f4
> 9   <<00000000>> 	0x017ad350 0 + 0x17ad350
> 10  <<00000000>> 	0x017acd64 0 + 0x17acd64
> 11  <<00000000>> 	0x05e67b50 0 + 0x5e67b50
> 12  <<00000000>> 	0x05d26530 0 + 0x5d26530
> 13  <<00000000>> 	0x030d55a8 0 + 0x30d55a8
> 14  libCocoaSharpGlue.dylib  	0x011ec1cc glue_forwardInvocation + 
> 0x16c (Glue.m:260)
> 15  com.apple.Foundation     	0x909fcfd0 
> -[NSObject(NSForwardInvocation) forward::] + 0x198
> 16  libobjc.dylib            	0x90836810 _objc_msgForward + 0xb0
> 17  libobjc.dylib            	0x90836734 objc_msgSendv + 0xb4
> 18  libCocoaSharpGlue.dylib  	0x011ec458 glue_implementMethod + 0x24c 
> (Glue.m:308)
> 19  com.apple.AppKit         	0x92e78224 -[NSApplication 
> sendAction:to:from:] + 0x6c
> 20  com.apple.AppKit         	0x92eada44 -[NSMenu 
> performActionForItemAtIndex:] + 0x188
> 21  com.apple.AppKit         	0x92ef22e4 -[NSCarbonMenuImpl 
> performActionWithHighlightingForItemAtIndex:] + 0x68
> 22  com.apple.AppKit         	0x92ef8c14 -[NSMenu 
> performKeyEquivalent:] + 0x104
> 23  com.apple.AppKit         	0x92ed7ccc -[NSApplication 
> _handleKeyEquivalent:] + 0x124
> 24  com.apple.AppKit         	0x92df53dc -[NSApplication sendEvent:] + 
> 0xa5c
> 25  com.apple.AppKit         	0x92dfdc54 -[NSApplication run] + 0x240
> 26  <<00000000>> 	0x05e6b320 0 + 0x5e6b320
> 27  <<00000000>> 	0x05e6b1ac 0 + 0x5e6b1ac
> 28  mono                     	0x000613a8 mono_runtime_invoke_array + 
> 0x2a4 (object.c:1909)
> 29  mono                     	0x00079788 ves_icall_InternalInvoke + 
> 0x294 (icall.c:2370)
> 30  <<00000000>> 	0x017ae9d8 0 + 0x17ae9d8
> 31  <<00000000>> 	0x017ae1f4 0 + 0x17ae1f4
> 32  <<00000000>> 	0x017ad350 0 + 0x17ad350
> 33  <<00000000>> 	0x017acd64 0 + 0x17acd64
> 34  <<00000000>> 	0x011e4ac8 0 + 0x11e4ac8
> 35  <<00000000>> 	0x05e6b0f4 0 + 0x5e6b0f4
> 36  <<00000000>> 	0x05e6b078 0 + 0x5e6b078
> 37  <<00000000>> 	0x004c7344 0 + 0x4c7344
> 38  <<00000000>> 	0x004c7088 0 + 0x4c7088
> 39  <<00000000>> 	0x004c640c 0 + 0x4c640c
> 40  mono                     	0x0006105c mono_runtime_exec_main + 
> 0x110 (object.c:1766)
> 41  mono                     	0x00060cac mono_runtime_run_main + 0x210 
> (object.c:1628)
> 42  mono                     	0x000040d8 mono_main + 0x91c 
> (driver.c:893)
> 43  mono                     	0x00002468 _start + 0x188 (crt.c:267)
> 44  dyld                     	0x8fe1a558 _dyld_start + 0x64
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list