[Bug #3136] reuse of singleton method definition causes SEGV

Bug #3136: reuse of singleton method definition causes SEGV
http://redmine.ruby-lang.org/issues/show/3136

e$B5/I<<Te(B: Yusuke E.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2010-04-12 trunk 27317) [i686-linux]

e$B1sF#$G$9!#e(B

e$B0J2<$Ge(B SEGV e$B$7$^$9!#e(B

def overlaid(obj)
class << obj
def reverse
super
end
end
end

overlaid(str = “123”) # (1)
overlaid(ary = [1,2,3]) # (2)
str.reverse # (3) => SEGV

e$B0lO"[email protected]@$9$k$He(B:

  • (1) e$B$K$h$C$F!"e(Breverse e$B$Ne(B iseq e$B$,e(B “123”
    e$B$N%a%=%C%I$H$J$k!#e(B
    (reverse e$B$Ne(B iseq e$B$Ne(B klass e$B$K!Ve(BString
    e$B$r7Q>5$7$?FC0[%/%i%9!We(B
    e$B$,%;%C%H$5$l$ke(B)

  • (2) e$B$K$h$C$F!"e(Breverse e$B$Ne(B iseq e$B$,e(B [1,2,3]
    e$B$N%a%=%C%I$H$J$ke(B
    (reverse e$B$Ne(B iseq e$B$Ne(B klass e$B$K!Ve(BArray
    e$B$r7Q>5$7$?FC0[%/%i%9!We(B
    e$B$,e(B e$B>e=q$-e(B e$B$5$l$ke(B)

  • (3) e$B$K$h$C$F!"e(BString e$B$N%$%s%9%?%s%9$re(B self e$B$H$7$Fe(B
    reverse
    e$B$Ne(B iseq e$B$,<B9T$5$l$k!#$=$NCf$Ne(B super
    e$B$G8=:_<B9TCf$Ne(B iseq
    e$B$Ne(B klass (= Array e$B$r7Q>5$7$?FC0[%/%i%9e(B)
    e$B$r85$K8F$S=P$9e(B
    e$B%a%=%C%I$r7h$a$k!#$9$k$He(B Array#reverse
    e$B$,A*$P$l$F$7$^$&!#e(B

  • String e$B$N%$%s%9%?%s%9$re(B self e$B$H$7$Fe(B rb_ary_reverse
    e$B$,<B9Te(B
    e$B$5$l$F$7$^$&!#e(B

iseq e$B$Ne(B klass e$B$Ke(B super
e$B$N%3%s%F%-%9%H>pJs$r;}$?$;[email protected]_7W$,e(B
e$B%P%[email protected]$H;W$$$^$7$?!#e(B

e$B2r7hJ}K!$H$7$F$O!"e(B

  1. rb_iseq_t e$B0J30$Ge(B super e$B$N%3%s%F%-%9%H>pJs$r4IM}$9$ke(B
    (Ruby e$B%l%Y%k$N%a%=%C%I$G$be(B rb_method_entry_t e$B$Ne(B klass
    e$B$re(B
    e$B;H$&$h$&$K$9$k!)e(B)

  2. e$B%a%=%C%I$rDj5A$9$k$?$S$Ke(B rb_iseq_t e$B$rJ#@=$9$ke(B

e$B$r;W$$$D$-$^$7$?$,!"$I$A$i$b7k9=%?%U$=$&$JJQ99$G$9!#e(B

e$B0BDj$5$;$k$N$K;~4V$,$+$+$k$3$H$,M=A[$5$l$k$?$a!"$,$s$P$C$Fe(B
e$BAa$/D>$7$F$/[email protected]$5$$e(B > [email protected]$5$s!#e(B

e$B$^$?!"e(B[ruby-dev:40458] [email protected]$b5^$.L$G$*4j$$$7$^$9!#e(B


Yusuke E. [email protected]

e$B%A%1%C%He(B #3136 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B1sF#$G$9!#e(B

e$B0J2<$G$be(B SEGV e$B$^$?$OL$Dj5A5sF0$r$7$^$9!#e(B

Class.new do
define_method(:foo) { super() }.call
end

define_method e$B$Ke(B Proc e$B$,EPO?$5$l$k$3$H$G!"e(BProc
e$B$N%V%m%C%/$Ne(B iseq
e$B$Ne(B klass e$B$,99?7$5$l$F$7$^$$$^$9!#e(B
e$B$=$Ne(B Proc e$B$rD>@\8F$S=P$9$H!"e(Bcfp e$B$Ke(B method_entry
e$B$,>h$i$J$$$1$l$Ie(B
super [email protected]$N8uJd$K$J$C$F$7$^$$!"Mn$A$k$h$&$G$9!#e(B

e$B%V%m%C%/$Ne(B iseq e$B$Ne(B klass e$B$r85$Ke(B super
[email protected]$r7h$a$F$$$k$N$,0-$$$N$G!"e(B
[email protected]$($^$9!#e(B

e$B0c$&LdBj$+$HG:[email protected]$N$G!"EPO?$7$F$*$-$^$9!#e(B


Yusuke E. [email protected]

http://redmine.ruby-lang.org/issues/show/3136

e$B%A%1%C%He(B #3136 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B1sF#$G$9!#e(B

e$B%A%1%C%H=EJ#>pJs$NJdB-$G$9!#e(B

e$B$3$N%A%1%C%H$G:[email protected]@$7$?FbMF$Oe(B #2502 e$B$N=EJ#$G$7$?!#e(B

[email protected]@$7$?FbMFe(B (define_method e$B$Ne(B Proc e$B$ND>@\e(B call)
e$B$Oe(B
#2420 e$B$N=EJ#$G$7$?!#e(B

e$B$^$?!"[email protected]@$7$?FbMF$Oe(B #2402 e$B$N%Q%C%A$G!"e(BSEGV
e$B$K;j$kA0$Ke(B
e$BNc30$K$J$k$N$G!"H/>I$7$J$/$J$j$^$9e(B (e$BK<AE*$K2r7h$9$k$o$1$G$Oe(B
e$B$J$$$1$l$Ie(B )e$B!#e(B


Yusuke E. [email protected]

http://redmine.ruby-lang.org/issues/show/3136

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs