Project

General

Profile

Actions

Bug #19323

closed

Integer overflow in `Integer#<<`

Added by nobu (Nobuyoshi Nakada) over 1 year ago. Updated 12 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:111735]

Description

require 'rbconfig/sizeof'
char_bit = RbConfig::LIMITS["UCHAR_MAX"].bit_length
size_max = RbConfig::LIMITS["SIZE_MAX"]
size_bit_max = size_max * char_bit
1 << size_bit_max

The above code raises an "integer overflow" error.

-:5:in `<<': integer overflow: 4611686018427387905 * 4 > 18446744073709551615 (ArgumentError)
	from -:5:in `<main>'

It doesn't seem like a proper or intentional exception.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #18518: NoMemoryError + [FATAL] failed to allocate memory for twice 1 << largeRejectedActions
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|1cdf8ab07b24ebd16e93621957196e8b1d67f2ba.


[Bug #19323] Raise RangeError instead of integer overflow

Actions #3

Updated by Eregon (Benoit Daloze) over 1 year ago

  • Related to Bug #18518: NoMemoryError + [FATAL] failed to allocate memory for twice 1 << large added

Updated by usa (Usaku NAKAMURA) 12 months ago

  • Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: REQUIRED

backported into ruby_3_1 at 344249674f7a7835445a44695664897fa4b83f00

Updated by nagachika (Tomoyuki Chikanaga) 12 months ago

  • Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: REQUIRED to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: DONE

ruby_3_2 a048f7882a13e96080021a5bc13ef1fb293b4985 merged revision(s) 1cdf8ab07b24ebd16e93621957196e8b1d67f2ba.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0