[MacRuby-devel] [MacRuby] #307: eval destroys a singleton attribute (Segmentation fault)
MacRuby
ruby-noreply at macosforge.org
Sat Aug 8 12:29:13 PDT 2009
#307: eval destroys a singleton attribute (Segmentation fault)
------------------------+---------------------------------------------------
Reporter: dev@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone: MacRuby 0.5
Component: MacRuby | Keywords: eval
------------------------+---------------------------------------------------
hotconsole crashes after entering at least one expression and calling the
'clear'-command from menu
so I tried to narrow the problem to:
{{{
require 'hotcocoa'
include HotCocoa
class Test
def initialize
@win = window( :title => "HotConsole") do |win|
# win.will_close { exit }
end
class << @win
attr_accessor :target
end
@win.target = self
end
def run
$stderr.puts @win.target.inspect
# the eval in the next line destroys the @win.target. Disable it and
everything works fine!
$stderr.puts eval("42", TOPLEVEL_BINDING.dup, 'hotconsole', 100)
# the next line crashes with: unknown: [BUG] Segmentation fault
$stderr.puts @win.target.inspect
$stderr.puts "everything is fine!"
exit
end
end
class Application
def start
application :name => "HotConsole" do |app|
app.delegate = self
Test.new.run
end
end
end
Application.new.start
}}}
gives the result:
{{{
#-<Test:0x8004450a0>
42
unknown: [BUG] Segmentation fault
MacRuby version 0.5 (ruby 1.9.0) [universal-darwin9.0, x86_64]
Abort trap
}}}
Unfortunately enabling the "win.will_close..." causes the Segmentation
fault to disappear on my system, so I hope other people will see the same
behaviour! (obvisously this is memory layout dependant)
BTW, I didn´t use NSLog because it crashes on my system:
{{{
macruby -e "framework 'Cocoa'; NSLog 'test'"
}}}
gives:
{{{
unknown: [BUG] Segmentation fault
MacRuby version 0.5 (ruby 1.9.0) [universal-darwin9.0, x86_64]
Abort trap
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/307>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list