Re: [MacRuby-devel] MacRuby 0.8 - crash using Proc.new with NSArray.enumerateObjectsUsingBlock
Thank you Laurent,
Adding framework 'Foundation' has fixed the problem.
I must also apologise for putting 0.9 in the original title (a mistype) - of
course I am using 0.8
best wishes, Jonathan
On 13 Feb 2011, at 23:46, Laurent Sansonetti wrote:
> Hi Jonathan,
>
> Your snippet does not require the Foundation framework. Add the following
> line to your script
>
> framework 'Foundation'
>
> You will also need MacRuby 0.8 and the latest BridgeSupport Preview 3
> release. Then let us know if you still reproduce the crash.
>
> The snippet works fine in my environment :(
>
> Laurent
>
> On Feb 13, 2011, at 8:55 AM, Jonathan Waddilove wrote:
>
>> Hi, another MacRuby 0.9 question...
>>
>> I've been trying to use lambda and/or Proc.new to provide callback blocks
>> (as suggested in Matt's excellent draft book). Again I have seen discussions
>> about problems in this area and for me all the suggested variants of code
>> fail.
>>
>> Here's a snip of failing code:
>>
>> #!/usr/local/bin/macruby
>> puts "Ruby Version: #{RUBY_VERSION}, MacRuby Version: #{MACRUBY_VERSION}"
>>
>> a = [1, 2, 3, 4, 5,]
>>
>> a.enumerateObjectsUsingBlock(Proc.new {|obj, index, stop|
>>puts "I'll bet this never displays"
>>})
>>
>> and here's the resulting crash...
>>
>> Any suggestions? many thanks, Jonathan
>>
>>
>> Process: macruby [23078]
>> Path:
>> /Library/Frameworks/MacRuby.framework/Versions/0.8/usr/bin/macruby
>> Identifier: macruby
>> Version: ??? (???)
>> Code Type: X86-64 (Native)
>> Parent Process: ruby [23074]
>>
>> Date/Time: 2011-02-13 16:50:33.806 +
>> OS Version: Mac OS X 10.6.6 (10J567)
>> Report Version: 6
>>
>> Exception Type: EXC_BAD_ACCESS (SIGSEGV)
>> Exception Codes: KERN_INVALID_ADDRESS at 0x
>> Crashed Thread: 0 Dispatch queue: com.apple.main-thread
>>
>> Application Specific Information:
>> objc[23078]: garbage collection is ON
>>
>> Thread 0 Crashed: Dispatch queue: com.apple.main-thread
>> 0 ??? 00 0 + 0
>> 1 ??? 0x000102d63ac6 0 + 4342561478
>> 2 libmacruby.dylib 0x00010014a0b3 rb_vm_dispatch + 1331
>> 3 ??? 0x000102d5a536 0 + 4342523190
>> 4 ??? 0x000102d63806 0 + 4342560774
>> 5 libmacruby.dylib 0x000100162d53 rb_vm_run + 531
>> 6 libmacruby.dylib 0x0001000408f0 ruby_run_node + 80
>> 7 macruby 0x00010d28 main + 152
>> 8 macruby 0x00010c88 start + 52
>>
>> Thread 1:
>> 0 libSystem.B.dylib0x7fff88fe5f8a __workq_kernreturn +
>> 10
>> 1 libSystem.B.dylib0x7fff88fe639c _pthread_wqthread +
>> 917
>> 2 libSystem.B.dylib0x7fff88fe6005 start_wqthread + 13
>>
>> Thread 0 crashed with X86 Thread State (64-bit):
>> rax: 0x7fff5fbfddc0 rbx: 0x rcx: 0x7fff5fbfdf0f
>> rdx: 0x
>> rdi: 0x0002000bed00 rsi: 0x0002000bec00 rbp: 0x7fff5fbfdf40
>> rsp: 0x7fff5fbfdcf8
>> r8: 0x0002 r9: 0x0005 r10: 0x0001
>> r11: 0x000100af9000
>> r12: 0x0002000bec00 r13: 0x r14: 0x0005
>> r15: 0x
>> rip: 0x rfl: 0x00010246 cr2: 0x
>>
>> Binary Images:
>> 0x1 -0x10ff7 +macruby ??? (???)
>> <4408616F-9F77-025F-C278-91F945728AB0> /usr/local/bin/macruby
>> 0x13000 -0x100a29fd7 +libmacruby.dylib 0.8.0
>> (compatibility 0.8.0) <8910242D-90F3-32AC-A4CA-99D5C316AEB8>
>> /Library/Frameworks/MacRuby.framework/Versions/0.8/usr/lib/libmacruby.dylib
>>0x7fff5fc0 - 0x7fff5fc3bdef dyld 132.1 (???)
>> <486E6C61-1197-CC7C-2197-82CE505102D7> /usr/lib/dyld
>>0x7fff801f1000 - 0x7fff802aafff libsqlite3.dylib 9.6.0
>> (compatibility 9.0.0) <2C5ED312-E646-9ADE-73A9-6199A2A43150>
>> /usr/lib/libsqlite3.dylib
>>0x7fff802ba000 - 0x7fff80478fff libicucore.A.dylib 40.0.0
>> (compatibility 1.0.0) <781E7B63-2AD0-E9BA-927C-4521DB616D02>
>> /usr/lib/libicucore.A.dylib
>>0x7fff809d - 0x7fff80a8dff7 com.apple.CoreServices.OSServices
>> 357 (357) <7B22626F-D544-1955-CC53-240F4CACEB4A>
>> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
>>0x7fff815d5000 - 0x7fff815ebfef libbsm.0.dylib ??? (???)
>> <42D3023A-A1F7-4121-6417-FCC6B51B3E90> /usr/lib/libbsm.0.dylib
>>0x7fff817b9000 - 0x7fff817bdff7 libmathCommon.A.dylib 315.0.0
>> (compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5>
>> /usr/lib/system/libmathCommon.A.dylib
>>0x7fff81cbb000 - 0x7fff81d05ff7 com.apple.Metadata 10.6.3 (507.15)
>> <517
Re: [MacRuby-devel] MacRuby 0.9 - NSDate initWithTimeInterval:sinceDate: problem
Thank you Alan, I was obviously having a really bad day for mistyping and word blindness... best wishes, Jonathan regards, Jonathan Jonathan T Waddilove email: [email protected] web: jonathan.waddilove.net On 13 Feb 2011, at 19:52, Alan Skipp wrote: > I think you've just managed to get your variable names mixed up. You've used > 'cocoaFinishTime' where you should have used 'cocoaTime' > > last line should be: > puts "Cocoa Later time: #{cocoaFinishTime}, interval: > #{cocoaFinishTime.timeIntervalSinceDate(cocoaTime)} seconds" > > al > > > On 13 Feb 2011, at 16:42, Jonathan Waddilove wrote: > >> Hi, I have been trying to use the NSDate initWithTimeInterval:sinceDate: >> method to measure elapsed times. >> >> I know there has been some discussion about the mapping from Cocoa NSDate to >> Ruby Time and back but I'm not sure if this is supposed to be working now? >> >> Here's a snip of code that calculates the interval using Ruby Time and then >> NSDate >> >> #!/usr/local/bin/macruby >> puts "Ruby Version: #{RUBY_VERSION}, MacRuby Version: #{MACRUBY_VERSION}" >> >> puts "\n\nRuby vesion - works as expected" >> point_in_time = Time.now >> puts "Ruby start time #{point_in_time}" >> sleep(1) >> later_time = Time.now >> puts "Later time: #{later_time}, interval: #{later_time - point_in_time} >> seconds" >> >> puts "\n\nFailing Cocoa version" >> cocoaTime = NSDate.date >> puts "Coca start time: #{cocoaTime}" >> sleep(1) >> cocoaFinishTime = NSDate.date >> puts "Cocoa Later time: #{cocoaFinishTime}, interval: >> #{cocoaFinishTime.timeIntervalSinceDate( cocoaFinishTime)} seconds" >> >> >> And here's the output, note the NSDate sees zero intervale... >> Ruby Version: 1.9.2, MacRuby Version: 0.8 >> >> >> Ruby vesion - works as expected >> Ruby start time 2011-02-13 16:33:23 + >> Later time: 2011-02-13 16:33:24 +, interval: 1.000694 seconds >> >> >> Failing Cocoa version >> Coca start time: 2011-02-13 16:33:24 + >> Cocoa Later time: 2011-02-13 16:33:25 +, interval: 0.0 seconds >> >> User error? or do I need to file a ticket? >> >> Best wishes and thanks, Jonathan >> >> ___ >> MacRuby-devel mailing list >> [email protected] >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > > ___ > MacRuby-devel mailing list > [email protected] > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] WeakRef advice
Hello everyone,
I've been doing some research into weak references in ruby and from what I've
read it seems that Ruby's WeakRef implementation is both inefficient and
unsafe. Here is the thread discussing the matter:
http://redmine.ruby-lang.org/issues/show/4168
As Macruby has a different garbage collector I don't know if these problems are
also present?
I am working on a blocks based API for Key Value Coding and need to keep a weak
reference to objects.
Here is a very basic example of how this would look in garbage collected
Objective-C:
@interface Observer : NSObject
{
__weak id obj;
}
@implementation
- (Observer *)initObservedObject:(id)object
{
obj = object;
}
Essentially I just need a Macruby equivalent of the above. Is there a simple
way to have a weak referenced instance variable in Macruby?
al
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] iokit
Has there been any progress with this ticket? http://www.macruby.org/trac/ticket/1126 Thanks, Joel -- - mac osx device driver ninja, kernel extensions and user-land usb drivers -++--- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont -++--- ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] WeakRef advice
Hi Alan,
MacRuby should have the same problem. ObjectSpace._id2ref in MacRuby basically
maps an object pointer value to a numerical description, and the GC recycles
objects.
I am curious why you need weak references, though. MacRuby is able to detect
and deal with reference cycles, so you shouldn't need to worry about leaks. Is
there another use case that I'm forgetting?
Laurent
On Feb 14, 2011, at 5:48 AM, Alan Skipp wrote:
> Hello everyone,
> I've been doing some research into weak references in ruby and from what I've
> read it seems that Ruby's WeakRef implementation is both inefficient and
> unsafe. Here is the thread discussing the matter:
> http://redmine.ruby-lang.org/issues/show/4168
>
> As Macruby has a different garbage collector I don't know if these problems
> are also present?
>
> I am working on a blocks based API for Key Value Coding and need to keep a
> weak reference to objects.
> Here is a very basic example of how this would look in garbage collected
> Objective-C:
>
> @interface Observer : NSObject
> {
>__weak id obj;
> }
>
> @implementation
> - (Observer *)initObservedObject:(id)object
> {
> obj = object;
> }
>
>
> Essentially I just need a Macruby equivalent of the above. Is there a simple
> way to have a weak referenced instance variable in Macruby?
>
> al
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Issue with running unit tests when requiring rubygems
On Feb 13, 2011, at 05:56 , Gabriel Ayuso wrote:
> I reinstalled the minitest and mocha gems to the following versions:
> minitest-2.0.2, mocha-0.9.12
> The same issue I described before occurred once again.
>
> Here's the code I ran on macirb and the result:
>
> require 'rubygems'#=> true
> gem 'minitest'#=> true
> require 'test/unit' #=> true
> require 'mocha' #=> true
> class QuickTest < Test::Unit::TestCase
>def test_quick
> obj = mock('obj')
> obj.expects(:a).returns(true)
> assert( obj.a )
>end
> end # => nil
> exit
I can confirm this with the following minimal repro:
require "rubygems"
require "isolate"
Isolate.now! :system => false do
gem "minitest"
gem "mocha"
end
gem "minitest"
require "minitest/autorun"
require "mocha"
class QuickTest < MiniTest::Unit::TestCase
def test_quick
obj = mock("obj")
end
end
The test only fails on macruby and with mocha. I'll file a ticket.
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Issue with running unit tests when requiring rubygems
On Feb 14, 2011, at 15:23 , Ryan Davis wrote: > The test only fails on macruby and with mocha. I'll file a ticket. https://www.macruby.org/trac/ticket/1161 ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Issue with running unit tests when requiring rubygems
here is the workaround:
require "rubygems"
require "isolate"
Isolate.now! :system => false do
gem "minitest"
gem "mocha"
end
class Module
def remove_method x
# do nothing
end
end if defined?(RUBY_ENGINE) and RUBY_ENGINE == "macruby"
gem "minitest"
require "minitest/autorun"
require "mocha"
class QuickTest < MiniTest::Unit::TestCase
def test_quick
obj = mock("obj")
end
end
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
