[MacRuby-devel] 0.2 available for testing

Stephen Bannasch stephen.bannasch at deanbrook.org
Fri Jun 6 13:57:49 PDT 2008


At 10:27 PM -0700 6/5/08, Laurent Sansonetti wrote:
>On Jun 5, 2008, at 9:53 PM, Stephen Bannasch wrote:
>
>> At 2:58 PM -0700 6/5/08, Laurent Sansonetti wrote:
>>> On Jun 5, 2008, at 2:41 PM, Stephen Bannasch wrote:
>>>
>>>> At 4:28 PM -0400 6/5/08, Richard Kilmer wrote:
>>>>> On Jun 5, 2008, at 4:22 PM, Stephen Bannasch wrote:
>>>>>> After clicking the Spin button the circle spins for a little 
>>>>>> over 1s
>>>>>> before the program crashes.
>>>>>
>>>>> Do you have the iPhone sdk installed by chance?
>>>>
>>>> No.
>>>>
>>>>> Just FYI, I svn up'd, built and CircleView runs just great.
>>>>
>>>> Hmmm ... is there a way to run it with gdb and watch the variable
>>>> @layoutManager and break and display a stack frame when it is set to
>>>> nil?
>>>
>>> It's not as easy.
>>>
>>> In rb_main.rb, add the following line at the very beginning of the 
>>> file:
>>>
>>>  GC.disable
>>>
>>> Then, try to reproduce the bug. If it doesn't reproduce, then it's a
>>> GC bug.
>>
>> I added GC.disable and clicking Spin worked. So it's a GC bug -- 
>> what do I need to look for to fix it?
>>
>> Before I disabled the GC I did this investigation:
>>
>>
>> I setup a counter to find out how many times the 
>> glyphRange.location.upto do loop is called.
>>
>>  def initWithFrame(frame)
>>    super(frame)
>>
>>    @glyphRange_location_call_count = 0
>>
>> And then I added these debugging statements inside the 
>> glyphRange.location.upto do loop
>>
>>    glyphRange.location.upto(glyphRange.location + glyphRange.length 
>> - 1) do |i|
>>      $stderr.puts "@layoutManager == nil: #{@layoutManger == nil}, 
>> times called: #{@glyphRange_location_call_count}"
>>      @glyphRange_location_call_count += 1
>>
>> This is what happens when I start the app:
>>
>> [Session started at 2008-06-05 20:01:10 -0400.]
>> @layoutManager == nil: true, times called: 0
>> ...
>> @layoutManager == nil: true, times called: 141
>>
>> Then I click the Spin button:
>>
>> #<NSCFTimer:0x16497e0>
>> @layoutManager == nil: true, times called: 142
>> @layoutManager == nil: true, times called: 143
>> ...
>> @layoutManager == nil: true, called: 2432
>> @layoutManager == nil: true, called: 2433
>> /Users/stephen/Desktop/CircleView/build/Release/CircleView.app/
>> Contents/Resources/CircleView.rb:66:in `block in drawRect': 
>> undefined method `+' for nil:NilClass (NoMethodError)
>>	from /Users/stephen/Desktop/CircleView/build/Release/CircleView.app/
>> Contents/Resources/CircleView.rb:53:in `upto'
>>	from /Users/stephen/Desktop/CircleView/build/Release/CircleView.app/
>> Contents/Resources/CircleView.rb:53:in `drawRect'
>>	from /Users/stephen/Desktop/CircleView/build/Release/CircleView.app/
>> Contents/Resources/rb_main.rb:22:in `NSApplicationMain'
>>	from /Users/stephen/Desktop/CircleView/build/Release/CircleView.app/
>> Contents/Resources/rb_main.rb:22:in `<main>'
>>
>> Ths is repeatable however the number of iterations before the crash 
>> varies.
>>
>> I don't understand why @layoutManger appears to be nil the whole time.
>
>So, I suspect the GC prematurely collect some ivars, including 
>@layoutManager.
>
>Fixing this problem is not easy, the bug is most probably in 
>variable.c. One thing i would do is to setup a breakpoint in 
>__rb_objc_finalize when *(Class *)obj == <the address of 
>NSLayoutManager>. Then, verify why there is no reference to that object.
>
>The problem: I cannot reproduce this crash. And all people I asked 
>about also cannot reproduce it.
>
>So, I will try to reproduce the crash by writing a small similar test 
>case and stress the GC. In the meantime, I will still release 0.2 

Interesting I found the following in /usr/local/bin:

erb -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/erb
gem -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/gem
irb -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/irb
macerb -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/macerb
macgem -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/macgem
macirb -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/macirb
macrake -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/macrake
macrdoc -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/macrdoc
macri -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/macri
macruby -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/macruby
mactestrb -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/mactestrb
rake -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/rake
rdoc -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/rdoc
ri -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/ri
ruby -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/ruby
testrb -> ../../..///Library/Frameworks/MacRuby.framework/Versions/Current/usr/bin/testrb

I deleted all of it and erased and rechecked out the testing branch.

That updated the svn revision from 249 to 256.

I now get an error doing the install:

cd MacRuby
rm -rf src
svn co http://svn.macosforge.org/repository/ruby/MacRuby/branches/testing src
cd src
autoconf
./configure --enable-framework --enable-fat-binary --program-prefix=mac
make
sudo make install-nodoc

... results in ...

installing binary commands
installing command scripts
installing library scripts
installing headers
installing manpages
installing extension objects
installing extension scripts
installing Xcode templates
installing samples
/Users/stephen/dev/MacRuby/src/lib/fileutils.rb:1437:in `fu_check_options': undefined method `keys' for [493]:NSCFArray (NoMethodError)
	from /Users/stephen/dev/MacRuby/src/lib/fileutils.rb:196:in `mkdir_p'
	from ./instruby.rb:156:in `makedirs'
	from ./instruby.rb:178:in `block in install_recursive'
	from ./instruby.rb:164:in `glob'
	from ./instruby.rb:164:in `install_recursive'
	from ./instruby.rb:430:in `install_stuff'
	from ./instruby.rb:438:in `<main>'
make: *** [do-install-nodoc] Error 1



More information about the MacRuby-devel mailing list