Hi,

At Thu, 11 Dec 2008 14:00:33 +0900,
Akinori MUSHA wrote in [ruby-core:20471]:
> The attached change is planned to be merged but it causes a coredump.
> 
> knu@daemon[1]% ruby-1.8 -rstringio -e 'x = StringIO.new("a\nb\nc"); e = x.each; e.each{|i|p i}; e.rewind; e.each{|i| p i }' 
> "a\n"
> "b\n"
> "c"
> zsh: illegal hardware instruction (core dumped)  ruby-1.8 -rstringio -e

SEGV without [BUG] message means system stack overflow.

$ ./ruby -rstringio -e 'x=StringIO.new("a\nb\nc"); e=x.each; e.each{|i|p i}; e.rewind; e.each{|i|p i}'
ruby 1.8.7 (2008-12-09 ruby_1_8 20587) [i686-linux]
"a\n"
"b\n"
"c"
/home/nobu/src/ruby/stable-debug/src/lib/generator.rb:192: warning: method redefined; discarding old next
/home/nobu/src/ruby/stable-debug/src/lib/generator.rb:204: warning: method redefined; discarding old rewind
/home/nobu/src/ruby/stable-debug/src/lib/generator.rb:151:in `rewind': stack level too deep (SystemStackError)
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:205:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:152:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:205:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:152:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:205:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:152:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:205:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:152:in `rewind'
	 ... 4440 levels...
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:205:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:152:in `rewind'
	from /home/nobu/src/ruby/stable-debug/src/lib/generator.rb:205:in `rewind'
	from -e:1

genenrator.rb required by Enumerator#rewind in enumerator.c
overrides he methods defined in C.

-- 
Nobu Nakada