From: hanmac@... Date: 2015-02-27T08:36:04+00:00 Subject: [ruby-core:68335] [Ruby trunk - Bug #10913] Enum#each_slice is crashing with Bignum as an argument Issue #10913 has been updated by Hans Mackowiak. i cant repoduce it with my ruby versions 2.1.2 and ruby 2.3.0dev [1] pry(main)> [1,2,3].each_slice(500000000000000000).to_a NoMemoryError: failed to allocate memory from (pry):1:in `each_slice' [2] pry(main)> [1,2,3].each_slice(5000000000000000000).to_a ArgumentError: array size too big from (pry):2:in `each_slice' [3] pry(main)> [1,2,3].each_slice(50000000000000000000).to_a RangeError: bignum too big to convert into `long' from (pry):3:in `each_slice' imo each_slice might be optimiced if the parameter is bigger than the total array/enum size ... ---------------------------------------- Bug #10913: Enum#each_slice is crashing with Bignum as an argument https://bugs.ruby-lang.org/issues/10913#change-51682 * Author: arup rakshit * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin12.0] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- [shreyas@~ (master)]$ rvm use 2.1.2 Using /Users/shreyas/.rvm/gems/ruby-2.1.2 [shreyas@~ (master)]$ pry `[1] pry(main)> [1,2,3].each_slice(50000000000000000).to_a pry(948,0x7fff73abb180) malloc: *** mmap(size=400000000000000000) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug pry(948,0x7fff73abb180) malloc: *** mmap(size=400000000000000000) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug NoMemoryError: failed to allocate memory from (pry):1:in `each_slice' [2] pry(main)>` -- https://bugs.ruby-lang.org/