Project

General

Profile

Actions

Bug #1901

closed

Segfault for Enumerable#count When Aliased to #size

Added by runpaint (Run Paint Run Run) over 14 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-08-05 trunk 24397) [i686-linux]
Backport:
[ruby-core:24794]

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

enumerable-alias (909 KB) enumerable-alias runpaint (Run Paint Run Run), 10/27/2009 04:36 AM
Actions #1

Updated by runpaint (Run Paint Run Run) over 14 years ago

=begin
This still occurs on trunk. May I suggest it block 1.9.2? (The, rather impressive, stack trace is attached).
=end

Actions #2

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

Actions #3

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 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

Actions #4

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0