[MacRuby] #228: Crash in my NSOutlineView data source
#228: Crash in my NSOutlineView data source --------------------------------+------------------------------------------- Reporter: cyberfox@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 1.0 Component: MacRuby | Keywords: crash --------------------------------+------------------------------------------- Greetings, I am at a loss; I've thrown away two days trying to figure out what it might be in my code, and countless variations on the theme of 'what data will this allow?' I've tried a deep hash, recursive arrays, and now a custom Pair structure, and it always blows up at a certain point _eventually_, and not in a nice Ruby way. :) I've figured out so much, but I'm fully stymied on getting NSOutlineView working with in my app. Specifically, it appears that some data is being corrupted in memory, and when it's being referenced, it's crashing to gdb. My application is at http://github.com/cyberfox/fallout3 and is my first attempt at a MacRuby app. I don't really know Cocoa either, although I was able to figure out a lot. If you run it, and paste the following data: {{{ #1234 #4321 #1245 #2143 #5432 #3412 }}} into the TextView, then click 'Analyze', then try to open up some of the entries in the OutlineView on the right. You'll see the crash after one or two levels. I tried 0.3, I tried trunk, and then 0.4 was released, and I jumped on that. Nothing works. It's entirely possible I'm doing something wrong; I figured out how to write a NSOutlineView data source by the seat of my pants, and it's obviously possible I'm getting it wrong. But I can't imagine that I'm getting it wrong in a way that's letting me stomp on memory from Ruby... Please help me understand this; I really believe it shouldn't be crashing to GDB, even if I've really screwed up my algorithm. When debugging an earlier version (it used array pairs and .first and .last), I found it died at ruby.h:1149 which was a reference to *(Class *)obj == (Class)rb_cFixnum and it was blowing up because obj was 0xffffffff, obviously bad. I believe that something is getting stomped on; and my program is showing it consistently. It is likely my fault, but it shouldn't be _possible_... Please try it and let me know what is going on... -- Morgan Schweers -- Ticket URL: <http://www.macruby.org/trac/ticket/228> MacRuby <http://macruby.org/>
#228: Crash in my NSOutlineView data source --------------------------------+------------------------------------------- Reporter: cyberfox@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 1.0 Component: MacRuby | Keywords: crash --------------------------------+------------------------------------------- Comment(by cyberfox@…): Current backtrace failure from 0.4 as just downloaded. {{{ #0 0x002bf09b in ivar_get () #1 0x002edc16 in vm_call_method () #2 0x002ddbaf in vm_eval () #3 0x002e822b in vm_eval_body () #4 0x002e9714 in vm_call0 () #5 0x0030271b in rb_ruby_to_objc_closure_handler_main () #6 0x00302978 in rb_ruby_to_objc_closure_handler () #7 0x94283424 in ffi_closure_SYSV () #8 0x9155bdee in -[NSOutlineView _dataSourceValueForColumn:row:] () #9 0x9155ba18 in -[NSTableView preparedCellAtColumn:row:] () #10 0x9155b87c in -[NSTableView _drawContentsAtRow:column:withCellFrame:] () #11 0x9155b7ea in -[NSOutlineView _drawContentsAtRow:column:withCellFrame:] () #12 0x9155adb2 in -[NSTableView drawRow:clipRect:] () #13 0x915001a0 in -[NSTableView drawRowIndexes:clipRect:] () #14 0x9150002a in -[NSOutlineView drawRowIndexes:clipRect:] () #15 0x914fec84 in -[NSTableView drawRect:] () #16 0x9158f29c in -[NSView _drawRect:clip:] () #17 0x9158cb0d in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] () #18 0x9158d543 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] () #19 0x9158d543 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] () #20 0x9158d543 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] () #21 0x9158d543 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] () #22 0x9158c02b in -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] () #23 0x91588b4f in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] () #24 0x914c9523 in -[NSView displayIfNeeded] () #25 0x914c90d1 in -[NSWindow displayIfNeeded] () #26 0x914c8ef4 in _handleWindowNeedsDisplay () #27 0x95ae79a2 in __CFRunLoopDoObservers () #28 0x95ae8cfc in CFRunLoopRunSpecific () #29 0x95ae9cd8 in CFRunLoopRunInMode () #30 0x95cef2c0 in RunCurrentEventLoopInMode () #31 0x95cef012 in ReceiveNextEventCommon () #32 0x95ceef4d in BlockUntilNextEventMatchingListInMode () #33 0x914c6d7d in _DPSNextEvent () #34 0x914c6630 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #35 0x91597ee3 in -[NSWindow nextEventMatchingMask:] () #36 0x916a9877 in -[NSMouseTracker trackWithEvent:inView:withDelegate:] () #37 0x915ee58c in -[NSOutlineView mouseDown:] () #38 0x915951a3 in -[NSWindow sendEvent:] () #39 0x91561d49 in -[NSApplication sendEvent:] () #40 0x914bf69f in -[NSApplication run] () #41 0x9148c8a4 in NSApplicationMain () #42 0x942831dd in .LCFI1 () #43 0x94283771 in ffi_call () #44 0x00303330 in rb_bsfunc_call () #45 0x002ed45e in vm_call_method () #46 0x002ddbaf in vm_eval () #47 0x002e822b in vm_eval_body () #48 0x002e84be in rb_iseq_eval () #49 0x00209ec9 in ruby_exec_node () #50 0x0020d050 in ruby_run_node () #51 0x002fb175 in macruby_main () #52 0x00001fed in main (argc=1, argv=0xbffff664) at /Users/mrs/Documents/Fallout 3 Hackers Helper/main.m:13 }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/228#comment:2> MacRuby <http://macruby.org/>
#228: Crash in my NSOutlineView data source --------------------------------+------------------------------------------- Reporter: cyberfox@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: Component: MacRuby | Resolution: invalid Keywords: crash | --------------------------------+------------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => invalid * milestone: MacRuby 1.0 => Comment: This isn't a bug in MacRuby but a bug in your code. You must always return unique objects from the data source methods. In your outlineView:child:ofItem: implementation you are returning new Pair objects, this will very likely crash the outline view because it does not retain the objects. http://developer.apple.com/documentation/Cocoa/Conceptual/OutlineView/Articl... I recommend to cache the Pair objects and always return the same instances. -- Ticket URL: <http://www.macruby.org/trac/ticket/228#comment:3> MacRuby <http://macruby.org/>
#228: Crash in my NSOutlineView data source --------------------------------+------------------------------------------- Reporter: cyberfox@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: Component: MacRuby | Resolution: invalid Keywords: crash | --------------------------------+------------------------------------------- Comment(by cyberfox@…): Greetings, Ah; thank you! That's what I needed to know. I figured there was something deeper that I was missing, but being new to Cocoa, I didn't even know what to look for. The key line appears to be ''The data source is in turn responsible for retaining all of the objects it provides to an outline view, and updating the outline view when there’s a change to the model. It is therefore not safe to release the root item—or any children—until you’re no longer displaying it in the outline view.'' Presumably they're being released by the GC in between accesses. Thanks very much for the pointer! -- Morgan Schweers -- Ticket URL: <http://www.macruby.org/trac/ticket/228#comment:4> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby