[MacRuby] #1354: Segfault occurs when duplicate the Class which is been autoloaded and use constant of duplicated Class.

MacRuby ruby-noreply at macosforge.org
Tue Jul 5 20:33:57 PDT 2011


#1354: Segfault occurs when duplicate the Class which is been autoloaded and use
constant of duplicated Class.
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  blocker               |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 Test Script:
 {{{
 #!ruby
 FILE = "/tmp/auto_load.rb"

 File.open(FILE, "w") {|f|
   f.puts <<"EOS"
 class Foo
   CONST = "hello, world"
 end
 EOS
 }

 class Foo
   autoload :CONST, FILE
 end
 Bar = Foo.dup

 p Foo.autoload?(:CONST) # => expect "/tmp/auto_load.rb"
 p Bar.autoload?(:CONST) # => expect "/tmp/auto_load.rb"
 p Foo::CONST # => expect "hello, world"
 p Bar::CONST # => expect NameError
 }}}

 Result:
 {{{
 $ ruby19 ~/tmp/t.rb
 "/tmp/auto_load.rb"
 "/tmp/auto_load.rb"
 "hello, world"
 /Users/watson/tmp/t.rb:19:in `<main>': uninitialized constant Bar::CONST
 (NameError)

 $ DYLD_LIBRARY_PATH=. ./macruby ~/tmp/t.rb
 "/tmp/auto_load.rb"
 "/tmp/auto_load.rb"
 "hello, world"
 zsh: segmentation fault  DYLD_LIBRARY_PATH=. ./macruby ~/tmp/t.rb
 }}}

 BackTrace:
 {{{
 Program received signal EXC_BAD_ACCESS, Could not access memory.
 Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000010
 0x000000010009af0e in st_delete (table=0x0, key=0x7fff5fbfdab0,
 value=0x7fff5fbfdad0) at st.c:536
 536         if (table->entries_packed) {
 (gdb) bt
 #0  0x000000010009af0e in st_delete (table=0x0, key=0x7fff5fbfdab0,
 value=0x7fff5fbfdad0) at st.c:536
 #1  0x00000001000bfb8d in autoload_delete (mod=8590070688, id=12421) at
 variable.c:1346
 #2  0x00000001000bfbe9 in rb_autoload_load (klass=8590070688, id=12421) at
 variable.c:1360
 #3  0x00000001000bfee2 in rb_const_get_0 (klass=8590070688, id=12421,
 exclude=0, recurse=2) at variable.c:1450
 #4  0x00000001000c0137 in rb_const_get (klass=8590070688, id=12421) at
 variable.c:1505
 #5  0x0000000100140ad3 in rb_vm_const_lookup_level (outer=8590070688,
 path=12421, lexical=false, defined=false, outer_stack=0x0) at vm.cpp:1346
 #6  0x0000000101600fa5 in ?? ()
 #7  0x0000000101600408 in ?? ()
 #8  0x0000000100149c8a in rb_vm_run (fname=0x2000a8cc0
 "/Users/watson/tmp/t.rb", node=0x2000256e0, binding=0x0,
 inside_eval=false) at vm.cpp:4121
 #9  0x000000010002858b in ruby_run_node (n=0x2000256e0) at eval.c:211
 #10 0x0000000100000be3 in main (argc=2, argv=0x100f1c040,
 envp=0x7fff5fbfde58) at main.cpp:40
 Current language:  auto; currently c
 (gdb)
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/1354>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list