Bugzilla – Bug 320145
[PPC] mono_get_lmf_addr crash
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by andreas.faerber@web.de 2006-01-25 12:05:57 MST ---- Description of Problem: When I use interop to add a new ObjC class to the ObjC runtime and let that class pose as NSObject, then I can override the dealloc method, calling the original NSObject implementation. This works fine as long as I do not display an alert sheet (using NSAlert's -(void)beginSheetModal...); shortly after I do, Mono aborts with an assertion failure in mono_get_lmf_addr in mini.c (as recently posted on the Mono list). Steps to reproduce the problem: 1. Create a native subclass of NSObject that overrides the dealloc method via a delegate into managed code. 2. Let that native class pose as NSObject, using either [TheNewClass poseAsClass:NSObject] ObjC method or p/invoked class_poseAs ObjC runtime function. 3. Create a new NSWindow instance. 4. Add an NSButton to the window's view. 5. Attach event handler code to the button that calls NSAlert's -(void)beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo: method. 6. Call [NSApplication sharedApplication's] -(void)run. 7. Compile, execute and click on the button to execute the event handling code. Actual Results: Mono aborts shortly after the sheet is displayed and reports an error in mono_get_lmf_addr function in mini.c (that should never be reached) on the console. If no alert sheet is displayed the app runs fine, all other callbacks or p/invoke calls I use execute as expected. If I do not pose as NSObject then the sheet is displayed as expected. Expected Results: A lot of callbacks to the managed dealloc method, but no abort of Mono runtime. How often does this happen? Every time an alert sheet is displayed. It happens with both mcs and gmcs. Additional Information: My Cocoa/ObjC bridge code and a test case are available on request. (posing and some other features are not supported or not working in the SVN Cocoa#) ---- Additional Comments From andreas.faerber@web.de 2006-01-25 12:08:55 MST ---- Created an attachment (id=169171) Test case ---- Additional Comments From andreas.faerber@web.de 2006-02-11 12:38:44 MST ---- The bridge code has been posted on the Cocoa-sharp list now. Any comments, questions, updates? ---- Additional Comments From vargaz@gmail.com 2006-02-12 09:00:57 MST ---- I know nothing about OSX, but that assert usually means a thread calls into managed code without being attached to the runtime. This usually happens with system threads calling event callbacks etc. where the callback happens to be a managed delegate passed to native code. This happens for asynch IO for example. If possible, those threads should be attached to the JIT by calling mono_thread_attach () from that thread. The proper fix (in the runtime) would be automatically attaching those threads to the JIT the first time they call into managed code. ---- Additional Comments From vargaz@gmail.com 2006-03-09 16:25:28 MST ---- *** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO77638 *** Imported an attachment (id=169171) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>OS X v10.3.9</cf_op_sys_details> This bug was marked DUPLICATE in the database it was moved from. Changing resolution to "MOVED"