[MacRuby-devel] MacRuby 0.9 EXC_BAD_ACCESS using NSPredicate against Core Data

Jonathan Waddilove jonathan at waddilove.net
Sat Feb 26 06:23:01 PST 2011


Just installed the new MacRuby 0.9 and I still have this problem.

I'm assuming it's something I've screwed up, and hints and tips greatly welcomed...

-Jonathan

On 24 Feb 2011, at 16:58, Jonathan Waddilove wrote:

> Hi, I'm trying to apply a predicate to a core data fetch and hitting EXC_BAD_ACCESS.
> 
> I've successfully used NSPredicate to filter an array's contents, but all my attempts to use NSPredicate with Coredata fail. 
> 
> I'm using framework 'Coredata' and framework 'Foundation' and this is the method that fails:
> 
>   def tagEntityExists?(tag, moc)
>     puts 'NodeProxy:tagEntityExists?'
>     entityDescription = NSEntityDescription.entityForName('Tag', inManagedObjectContext:moc)
>     request = NSFetchRequest.alloc.init()
>     request.setEntity(entityDescription)
>     
>     puts "Looking for tag: #{tag}"
>     predicate = NSPredicate.predicateWithFormat("name == %@", tag)
>     request.setPredicate(predicate)
>     
>     error = Pointer.new(:id)
>     
>     puts "request: #{request.description}"
>     begin
>       results = moc.executeFetchRequest(request, error:error)
>     rescue Exception => bang
>       puts bang
>     end
>     
>     unless results
>       puts "Fetch failure: #{error.description}"
>       return nil
>     end
>     puts "Will return: #{results.inspect}"
>     return results[0]
>   end
> 
> and here's the backtrace I get:
> 
> 
> #0  0x00007fff86ef42bc in _qfqp2_InitializedGlobalData ()
> #1  0x0000000102d61fe0 in ?? ()
> #2  0x000000010014a0b3 in rb_vm_dispatch ()
> #3  0x0000000102d5ab26 in ?? ()
> #4  0x0000000102d62c56 in ?? ()
> #5  0x000000010014bcd6 in rb_vm_dispatch ()
> #6  0x0000000102d5ab26 in ?? ()
> #7  0x0000000102d626da in ?? ()
> #8  0x000000010014e1f7 in rb_vm_yield_args ()
> #9  0x0000000100102ad8 in rb_yield ()
> #10 0x0000000100176f38 in rb_ary_freeze ()
> #11 0x000000010014bd16 in rb_vm_dispatch ()
> #12 0x0000000102d5ab26 in ?? ()
> #13 0x0000000102d62383 in ?? ()
> #14 0x000000010014bcd6 in rb_vm_dispatch ()
> #15 0x0000000102d5ab26 in ?? ()
> #16 0x0000000102d61906 in ?? ()
> #17 0x000000010014bcfb in rb_vm_dispatch ()
> #18 0x0000000102d5ab26 in ?? ()
> #19 0x0000000102d61542 in ?? ()
> #20 0x000000010014e1f7 in rb_vm_yield_args ()
> #21 0x0000000100102ad8 in rb_yield ()
> #22 0x0000000100176f38 in rb_ary_freeze ()
> #23 0x000000010014bd16 in rb_vm_dispatch ()
> #24 0x0000000102d5ab26 in ?? ()
> #25 0x0000000102d60c59 in ?? ()
> #26 0x000000010014bd16 in rb_vm_dispatch ()
> #27 0x0000000102d5ab26 in ?? ()
> #28 0x0000000102d6073d in ?? ()
> #29 0x000000010014bcfb in rb_vm_dispatch ()
> #30 0x00000001000f2bbe in rb_objc_isEqual ()
> #31 0x00000001000f2d8e in rb_objc_isEqual ()
> #32 0x00007fff837d1e9a in -[NSApplication sendAction:to:from:] ()
> #33 0x00007fff837f641e in -[NSMenuItem _corePerformAction] ()
> #34 0x00007fff837f6188 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] ()
> #35 0x00007fff83a7a279 in -[NSMenu _internalPerformActionForItemAtIndex:] ()
> #36 0x00007fff8392bf77 in -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] ()
> #37 0x00007fff837d895c in NSSLMMenuEventHandler ()
> #38 0x00007fff8109b9d5 in DispatchEventToHandlers ()
> #39 0x00007fff8109af28 in SendEventToEventTargetInternal ()
> #40 0x00007fff810b8beb in SendEventToEventTarget ()
> #41 0x00007fff810e7d51 in SendHICommandEvent ()
> #42 0x00007fff81114b86 in SendMenuCommandWithContextAndModifiers ()
> #43 0x00007fff81114b3e in SendMenuItemSelectedEvent ()
> #44 0x00007fff81114a3e in FinishMenuSelection ()
> #45 0x00007fff810f5d13 in MenuSelectCore ()
> #46 0x00007fff810f5468 in _HandleMenuSelection2 ()
> #47 0x00007fff836a97dd in _NSHandleCarbonMenuEvent ()
> #48 0x00007fff8367d317 in _DPSNextEvent ()
> #49 0x00007fff8367c7a9 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
> #50 0x00007fff8364248b in -[NSApplication run] ()
> #51 0x00007fff8363b1a8 in NSApplicationMain ()
> #52 0x0000000102d5ea5d in ?? ()
> #53 0x000000010014a658 in rb_vm_dispatch ()
> #54 0x0000000102d5ab26 in ?? ()
> #55 0x0000000102d5a4dc in ?? ()
> #56 0x0000000100162d53 in rb_vm_run ()
> #57 0x00000001000408f0 in ruby_run_node ()
> #58 0x000000010015a332 in macruby_main ()
> #59 0x0000000100000f20 in main (argc=1, argv=0x7fff5fbff6c8) at /Users/jonathan/Desktop/
> 
> Um, any suggestions? I see that there are previous list entries about this sort of problem but I think there are now all closed....
> 
> 
> Many thanks and regards, Jonathan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110226/082a3b51/attachment.html>


More information about the MacRuby-devel mailing list