#1188: Error when using define_method (getter) + valueForKey -----------------------------------+---------------------------------------- Reporter: thibault.ml@… | Owner: lsansonetti@… Type: defect | Status: new Priority: minor | Milestone: Component: MacRuby | Keywords: define_method valueForKey kvo -----------------------------------+---------------------------------------- {{{ #!ruby class A define_method(:foo) { nil } end p A.new.valueForKey(:foo) }}} This will crash with the following backtrace: {{{ Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000004 0x00007fff818ee5f0 in object_getClass () (gdb) bt #0 0x00007fff818ee5f0 in object_getClass () #1 0x00000001000e0904 in rb_objc_convert_immediate (obj=0x4) at objc.m:551 #2 0x0000000103b00e55 in ?? () #3 0x0000000100139343 in __rb_vm_objc_dispatch [inlined] () at /Users/naixn/Documents/Projets/MacRuby/dispatcher.cpp:480 #4 0x0000000100139343 in rb_vm_dispatch (_vm=0x100d23980, cache=0x100e48a20, top=8590064896, self=8590564352, klass=0x20005b5e0, sel=0x7fff81549320, block=0x0, opt=0 '\0', argc=1, argv=0x7fff5fbff578) at dispatcher.cpp:971 #5 0x0000000103b004e6 in ?? () #6 0x0000000103b001a7 in ?? () #7 0x0000000100152253 in rb_vm_run (fname=<value temporarily unavailable, due to optimizations>, node=0x20004bc20, binding=<value temporarily unavailable, due to optimizations>, inside_eval=false) at vm.cpp:3946 #8 0x000000010002d3e0 in ruby_run_node (n=0x20004bc20) at eval.c:211 #9 0x00000001000e8118 in main (argc=2, argv=0x100d1de20, envp=<value temporarily unavailable, due to optimizations>) at main.cpp:40 }}} However, this works: {{{ #!ruby class A def foo; nil; end; end p A.new.valueForKey(:foo) }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1188> MacRuby <http://macruby.org/>