[ruby-core:96026] [Ruby master Bug#16366] .count on endless range causes infinite loop

[email protected]
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-82874.20191129085124.414d41cfb902b068@ruby-lang.org>
Issue #16366 has been updated by ko1 (Koichi Sasada).


I introduce general solution.

Notes:

* there are no "(1..).count" test. can anyone write it?
* My fix can introduce additional problems because it increases interrupt points. Please report us if you find a problem on your app.
* My fix can introduce additional overhead (checking interrupts). I tried to reduce this overhead by rewriting checking code, however, the original code (no modification code) is fastest :p

----------------------------------------
Bug #16366: .count on endless range causes infinite loop
https://bugs.ruby-lang.org/issues/16366#change-82874

* Author: duffyjp (Jacob Duffy)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Out of curiosity, I tried:

``` ruby
(1..).count
```

Which resulted in an unkillable 100% CPU irb session. 

I expected either an exception or maybe `Infinity`

Thanks

---Files--------------------------------
enum_count_pass-16366.patch (765 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.