[ruby-cvs:57080] ko1:r49931 (trunk): * gc.c: fix memory leak by prepend method.

ko1 at ruby-lang.org ko1 at ruby-lang.org
Wed Mar 11 18:15:22 JST 2015


ko1	2015-03-11 18:15:20 +0900 (Wed, 11 Mar 2015)

  New Revision: 49931

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49931

  Log:
    * gc.c: fix memory leak by prepend method.
      It is easy to reproduce with such script:
        module M; def bar; end; end
        loop{
          Class.new do
            def foo; end
            prepend M
          end
        }
    * gc.c (obj_free): free T_ICLASS::m_tbl if it is created by prepend.
      To recognize it, check RICLASS_IS_ORIGIN flag.
    * gc.c (gc_mark_children): T_ICLASS objects only need to mark
      T_ICLASS::m_tbl if RICLASS_IS_ORIGIN is set.
    * gc.c (obj_memsize_of): count T_ICLASS if RICLASS_IS_ORIGIN is set.
    * internal.h (RCLASS_SET_ORIGIN): add to set RCLASS_SET_ORIGIN.
      TODO: The word `origin' seems not good name. We need to invent
      another good name.
    * class.c: use RCLASS_SET_ORIGIN().
    * class.c (class_alloc): zero clear rb_classext_t.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/gc.c
    trunk/internal.h


More information about the ruby-cvs mailing list