# Enumerator with certain built-in methods dumps core

**URL:** <https://www.ruby-forum.com/t/enumerator-with-certain-built-in-methods-dumps-core/132856>\
**Category:** Development\
**Created:** [March 25, 2008, 11:20am UTC](https://www.ruby-forum.com/t/enumerator-with-certain-built-in-methods-dumps-core/132856 "2008-03-25T11:20:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yusuke\_ENDOH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/c89c15/32.png) [@Yusuke\_ENDOH](https://www.ruby-forum.com/u/Yusuke_ENDOH)\
**Post date:** [March 25, 2008, 11:20am UTC](https://www.ruby-forum.com/t/enumerator-with-certain-built-in-methods-dumps-core/132856/1 "2008-03-25T11:20:32Z")

</div>

e$B1sF#$H?=$7$^$9!#e(B

e$B0J2\<$Ge(B 1.9 e$B$,Mn$A$^$9!#e(B

$ ./ruby -e ‘Module.enum\_for(:new).next’  
[BUG] Segmentation fault  
ruby 1.9.0 (2008-03-25 revision 15837) [i686-linux]

## – control frame ---------- c:0006 p:---- s:0011 b:0011 l:000010 d:000010 CFUNC :initialize c:0005 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :new c:0004 p:---- s:0007 b:0007 l:000006 d:000006 CFUNC :call c:0003 p:---- s:0005 b:0005 l:000004 d:000004 CFUNC :each c:0002 p:---- s:0003 b:0003 l:001888 d:000002 IFUNC c:0001 p:---- s:0001 b:-001 l:000000 d:000000 ------

## DBG\> : “:0:in `new'" DBG> : ":0:in`call’” DBG\> : “:0:in `each’” – backtrace of native function call (Use addr2line) – 0x80fb525 0x81235ce 0x812362b 0x80c9880 0xffffe440 0x8059f27 0x8080159 0x80fa425 0x805b58d 0x805b8b0 0x805ba3c 0x8080dda 0x80f19de 0x80fa425 0x8060f7e 0x80f19de 0x80fa425 0x805b58d 0x805b8b0 0x805dc43 0x805a258 0x805a2cf 0x81211fd 0x80fa425 0x805b58d 0x805b8b0 0x805dc43 0x805a258 0x805a2cf 0x812115f 0x80f96f0 0x80f992e 0x81009c5 0x805ab9f 0x805e250 0x8058641 0xb7dadea8 0x8058551

e$B%"%!\<%H$7$^$7$?e(B

e$B%3%s%H%m!\<%k%9%?%C%/$N:G=i$Ge(B module\_eval e$B$J$I$,8F$P$l$k$H!"e(B  
ruby e$B%l%Y%k$Ne(B cfp e$B$,B8:\_$7$J$$$?$a!“L58z$Je(B cfp  
e$B$K%”%/%;%9e(B  
e$B$9$k$h$&$G$9!#e(B

e$B$[$+$K$b0J2\<$N%W%m%0%i%`$?$A$GMn$A$^$9!#e(B

e$B!ye(B eval.c e$B$GMn$A$ke(B

- Object.enum\_for(:class\_eval).next

- Fiber.new(&Object.method(:class\_eval)).resume(“foo”)

- Thread.new(“foo”, &Object.method(:class\_eval)).join

- “foo”.enum\_for(:instance\_eval).next

- Fiber.new(&“foo”.method(:instance\_eval)).resume(“foo”)

- Thread.new(“foo”, &“foo”.method(:instance\_eval)).join

- enum\_for(:eval, “foo”).next

- Fiber.new(&Object.method(:eval)).resume(“foo”)

- Thread.new(“foo”, &Object.method(:eval)).join

- enum\_for(:local\_variables).next

- enum\_for(:block\_given?).next

e$B!ye(B ruby\_cref/SCOPE\_TEST/SCOPE\_CHECK/SCOPE\_SET e$B$GMn$A$ke(B

- enum\_for(:binding).next
- Module.enum\_for(:nesting).next
- Module.enum\_for(:constants).next
- Module.enum\_for(:attr, :foo).next
- Module.enum\_for(:attr\_reader, :foo).next
- Module.enum\_for(:attr\_writer, :foo).next
- Module.enum\_for(:attr\_accessor, :foo).next
- Module.enum\_for(:public).next
- Module.enum\_for(:protected).next
- Module.enum\_for(:private).next
- module M; enum\_for(:module\_function).next; end

e$B!ye(B rb\_backref\_set/rb\_backref\_get e$B$GMn$A$ke(B

- “abc”.enum\_for(:[], /./).next
- “abc”.enum\_for(:scan, /./).next
- “abc”.enum\_for(:sub, /./).next
- “abc”.enum\_for(:gsub, /./).next
- “abc”.enum\_for(:split, /./).next
- “abc”.enum\_for(:partition, /./).next
- “abc”.enum\_for(:rpartition, /./).next

“abc”.enum\_for(:scan, /./).next e$B$O\<B:]$K;H$$$=$&$G$9!#e(B

eval.c e$B$@$11~5^=hCV$r:n$C$F$\_$^$7$?$,!"$3$NJ}?K$@$He(B backref  
e$B\<~$j$Ge(B  
e$B=$@5$,$?$/$5$sI,MW$=$&$G$9!#e(B  
e$B:,K\E\*$JBP:v$r8!F$$7$?J}$,$$$$$+$b$7$l$^$;$s!#e(B

# e$B%3%s%H%m!\<%k%9%?%C%/$N:G=i$K%@%\_!\<$Ne(B ruby

e$B%l%Y%k$N%U%l!\<%`$r$\*$/!)e(B

# Index: eval.c

— eval.c (revision 15834)  
+++ eval.c (working copy)  
@@ -886,7 +886,7 @@  
rb\_thread\_t \*th = GET\_THREAD();  
rb\_control\_frame\_t \*cfp = th-\>cfp;  
cfp = vm\_get\_ruby\_level\_cfp(th,  
RUBY\_VM\_PREVIOUS\_CONTROL\_FRAME(cfp));

- if (GC\_GUARDED\_PTR\_REF(cfp-\>lfp[0])) {

- if (cfp && GC\_GUARDED\_PTR\_REF(cfp-\>lfp[0])) {  
return Qtrue;  
}  
else {  
@@ -1712,6 +1712,9 @@  
}  
else {  
rb\_control\_frame\_t \*cfp = vm\_get\_ruby\_level\_cfp(th, th-\>cfp);
- 

```
 if (!cfp) {

```

- rb\_raise(rb\_eArgError, “eval called at the stack bottom”);
- 

```
 }
 th->base_block = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp);
 th->base_block->iseq = cfp->iseq; /* TODO */

```

}  
@@ -1851,8 +1854,9 @@  
\*th-\>cfp-\>lfp = GC\_GUARDED\_PTR(&block);  
}

- while (!RUBY\_VM\_NORMAL\_ISEQ\_P(cfp-\>iseq)) {
- cfp = RUBY\_VM\_PREVIOUS\_CONTROL\_FRAME(cfp);

- cfp = vm\_get\_ruby\_level\_cfp(th, cfp);

- if (!cfp) {

- return (\*func) (args);  
}

- if (!cfp) return ary;

- while (1) {  
if (cfp-\>iseq) {  
for (i = 0; i \< cfp-\>iseq-\>local\_table\_size; i++) {
