Actions
Bug #9729
closedHash#each が無限ループする
Description
Hash のキーに配列を使い、
キーが同じ値になるように以下のような操作をすると
Hash#each が無限ループします。
h = {}
h[[]] = 1 # h #=> {[] => 1}
h.keys[0] << 1 # h #=> {[1] => 1}
h[[]] = 1 # h #=> {[1] => 1, [] => 1}
h.keys[1] << 1 # h #=> {[1] => 1, [1] => 1}
h.each { 1 } # 無限ループ
このコードは、Ruby 1.9.3-p545 だと、無限ループにならないことを確認しています。
また、以下のような手順で {[1] => 1, [1] => 1} を作った場合は、無限ループになりませんでした。
h = {}
h[[]] = 1 # h #=> {[] => 1}
h[[1]] = 1 # h #=> {[] => 1}
h.keys[0] << 1 # h #=> {[1] => 1, [1] => 1}
h.each { 1 } # 無限ループにならない
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Is duplicate of Bug #9646: Infinite loop at Hash#each added
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
- Status changed from Open to Assigned
- Assignee set to tarui (Masaya Tarui)
Updated by tarui (Masaya Tarui) over 10 years ago
- Status changed from Assigned to Closed
Applied in changeset r45642.
- st.c (st_foreach_check): chnage start point of search at check
from top to current. [ruby-dev:48047] [Bug #9646]
Updated by usa (Usaku NAKAMURA) over 10 years ago
- Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago
- Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE
Backported into ruby_2_1
branch at r46721.
Updated by usa (Usaku NAKAMURA) over 10 years ago
- Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE
backported into ruby_2_0_0
at r46747.
Actions
Like0
Like0Like0Like0Like0Like0Like0