[MacRuby-devel] NSInvocationOperation usage Segmentation fault
Sven A. Schmidt
sas at abstracture.de
Tue Oct 11 00:28:36 PDT 2011
Hi Alex,
I'm afraid I'm not able to help with your problem directly, but maybe I can provide an additional angle for debugging.
I've seen frequent crashes using Dispatch, which may be related. I've had to remove multi-threading from my Core Data Document-Based application due to these crashes and in the process of trying to figure out if it's me, my code, or the underlying framework that's causing it I've arrived at the following example. It reproducibly causes a EXC_BAD_INSTRUCTION and prints
unknown: [BUG] destination 0x8002989802c0 isn't in the auto zone
to the console.
The project is a "Core Data Document-Based Application" project (this is important) and simply includes a class A:
class A
def dispatch(&block)
puts "dispatch"
end
end
which is wired to an action in the document class:
class MyDocument < NSPersistentDocument
def init
super
if (self != nil)
@a = A.new
@queue = Dispatch::Queue.new('myqueue')
end
self
end
def windowNibName
"MyDocument"
end
def dispatch(sender)
@queue.async do
@a.dispatch do |t|
end
end
end
end
-----------------
The same setup works fine in a regular (no Cora Data, non-Document-Based) project. Note that even though the dispatch accepts a block but doesn't use it, this is actually required to trigger the error. Dispatching a method without parameters works fine.
I should note I'm using the 2011-09-23 nightly on Lion with Xcode 4.2 (GM).
Maybe that helps in tracking this down.
Cheers,
Sven
On Oct 11, 2011, at 8:19, Alex Greif wrote:
> The following code crashes with a segmentation fault.
> Any idea whether I misunderstood the usage or it is a macruby bug?
>
> thanks,
> ALex.
>
> ---code-------------------------------------------
> framework 'Foundation'
>
> class Foo
> def bar
> puts 'bar'
> end
> end
>
> operation = NSInvocationOperation.alloc.initWithTarget Foo.new, selector:
> 'bar', object: nil
>
> queue = NSOperationQueue.alloc.init
> queue.addOperation(operation)
>
> # run the main loop for 2 seconds
> NSRunLoop.currentRunLoop.runUntilDate(NSDate.dateWithTimeIntervalSinceNow(2.0))
>
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
--
Dr. Sven A. Schmidt
abstracture GmbH & Co. KG
Wilhelm-Theodor-Römheld-Straße 28
55130 Mainz
Fon +49 6131 696 29 0
Fax +49 6131 696 29 29
Mail sas at abstracture.de
Amtsgericht Mainz HRA 40625
USt-IdNr.: DE258454694
Persönlich haftender Gesellschafter:
abstracture IT-Beratungs- und Beteiligungsgesellschaft mbH, Sitz Mainz, Amtsgericht Mainz HRB 41357
Geschäftsführer: Dr. U. Koch, T. Meyer, A. Misok, Dr. S.A. Schmidt, Dr. V. Schönharting
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3770 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20111011/ede6bede/attachment.bin>
More information about the MacRuby-devel
mailing list