Bug #1901
closedSegfault for Enumerable#count When Aliased to #size
Description
=begin
$ cat /tmp/enum-size.rb
class E
include Enumerable
alias :size :count
def each
yield 1
end
end
p E.new.count
$ ruby -v /tmp/enum-size.rb
ruby 1.9.2dev (2009-08-05 trunk 24397) [i686-linux]
Segmentation fault
1.8.7 gives a SystemStackError. It would be nice if #count recognized #size was an alias and didn't try to invoke it.
=end
Files
Updated by runpaint (Run Paint Run Run) over 14 years ago
- File enumerable-alias enumerable-alias added
=begin
This still occurs on trunk. May I suggest it block 1.9.2? (The, rather impressive, stack trace is attached).
=end
Updated by matz (Yukihiro Matsumoto) over 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r25560.
Run Paint, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end
Updated by matz (Yukihiro Matsumoto) over 14 years ago
=begin
Hi,
In message "Re: [ruby-core:24794] [Bug #1901] Segfault for Enumerable#count When Aliased to #size"
on Thu, 6 Aug 2009 23:24:18 +0900, Run Paint Run Run redmine@ruby-lang.org writes:
| class E
| include Enumerable
| alias :size :count
| def each
| yield 1
| end
| end
|
| p E.new.count
|
| $ ruby -v /tmp/enum-size.rb
| ruby 1.9.2dev (2009-08-05 trunk 24397) [i686-linux]
| Segmentation fault
|
|1.8.7 gives a SystemStackError. It would be nice if #count recognized #size was an alias and didn't try to invoke it.
I fixed this by r25560, but I still consider the fix is implementation
dependent, so that some implementation might (and can) cause infinite
recursion.
matz.
=end
Updated by nobu (Nobuyoshi Nakada) over 14 years ago
=begin
Hi,
At Fri, 30 Oct 2009 08:09:02 +0900,
Yukihiro Matsumoto wrote in [ruby-core:26420]:
I fixed this by r25560, but I still consider the fix is implementation
dependent, so that some implementation might (and can) cause infinite
recursion.
Though I've missed the original report, it feels like there is
another bug that couldn't catch the stack overflow properly.
--
Nobu Nakada
=end