Projects

Ticket #307 (closed defect: fixed)

Opened 3 years ago

Last modified 14 months ago

eval destroys a singleton attribute (Segmentation fault)

Reported by: dev@… Owned by: lsansonetti@…
Priority: major Milestone:
Component: MacRuby Keywords: eval
Cc:

Description

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

Change History

Changed 14 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed
  • milestone MacRuby 0.5 deleted

Can you try again with a newer MacRuby? This problem is probably fixed now.

Note: See TracTickets for help on using tickets.