Project

General

Profile

Bug #13748

[PATCH] Fix mul overflow detection for LLP64 arch.

Added by larskanis (Lars Kanis) almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-07-15 trunk 57962) [x64-mingw32]
[ruby-core:82077]

Description

FIXNUMs are expected to fit into a long type, but the test in MUL_OVERFLOW_FIXNUM_P() is about the VALUE type. Since long is smaller than VALUE on LLP64, the overflow is not detected. As an exemplary result "2**31" evaluates to "-2147483648" instead of "2147483648" on Windows when built with gcc-7.1.0.

This also results in many more test failures as described in this github issue: https://github.com/oneclick/rubyinstaller2/issues/55

gcc versions before 7.1.0 don't provide __builtin_mul_overflow_p() and ruby-2.4.x doesn't use this function, so that they don't show this broken behavior.

The attached patch fixes the issue. However I'm currently unable to run a full "make test-all" to verify whether this fixes all gcc-7.1.0 related issues.


Files

Associated revisions

Revision c04b6232
Added by naruse (Yui NARUSE) over 1 year ago

Fix overflow detection for LLP64 arch [Bug #13748]

FIXNUMs are expected to fit into a long type, but the test is about a
VALUE type. Since long is < than VALUE on LLP64, the overflow is not
detected. As a result "2**31" evaluates to "-2147483648" on Windows with
gcc-7.1.0.
patched by Lars Kanis lars@greiz-reinsdorf.de

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 60019
Added by naruse (Yui NARUSE) over 1 year ago

Fix overflow detection for LLP64 arch [Bug #13748]

FIXNUMs are expected to fit into a long type, but the test is about a
VALUE type. Since long is < than VALUE on LLP64, the overflow is not
detected. As a result "2**31" evaluates to "-2147483648" on Windows with
gcc-7.1.0.
patched by Lars Kanis lars@greiz-reinsdorf.de

Revision 60019
Added by naruse (Yui NARUSE) over 1 year ago

Fix overflow detection for LLP64 arch [Bug #13748]

FIXNUMs are expected to fit into a long type, but the test is about a
VALUE type. Since long is < than VALUE on LLP64, the overflow is not
detected. As a result "2**31" evaluates to "-2147483648" on Windows with
gcc-7.1.0.
patched by Lars Kanis lars@greiz-reinsdorf.de

Revision 60019
Added by naruse (Yui NARUSE) over 1 year ago

Fix overflow detection for LLP64 arch [Bug #13748]

FIXNUMs are expected to fit into a long type, but the test is about a
VALUE type. Since long is < than VALUE on LLP64, the overflow is not
detected. As a result "2**31" evaluates to "-2147483648" on Windows with
gcc-7.1.0.
patched by Lars Kanis lars@greiz-reinsdorf.de

History

Updated by MSP-Greg (Greg L) almost 2 years ago

Just updated to gcc 7.1.0, and built trunk ruby 2.5.0dev (2017-07-15 trunk 59341) [x64-mingw32] with Lars' patch, and all tests results were as expected.

Build/test logs are at Bintray - z_logs_2017-07-15_59341.7z, build files at ruby_trunk.7z & ruby_trunk.7z.sig.

Test result tables updated at Ruby MinGW Test Results. This morning's doc updates to the site (Ruby trunk and Rails master) were generated using the build.

Lars - thanks again. For those that don't know, Lars is the creator of RubyInstaller2 for Windows. My build system is a little different, but both are MSYS2/MinGW based. My build system uses the runtime files he created for RI2, which allow the installation/compiling of extension gems.

#2

Updated by larskanis (Lars Kanis) over 1 year ago

  • Subject changed from Fix mul overflow detection for LLP64 arch. to [PATCH] Fix mul overflow detection for LLP64 arch.
#3

Updated by naruse (Yui NARUSE) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r60019.


Fix overflow detection for LLP64 arch [Bug #13748]

FIXNUMs are expected to fit into a long type, but the test is about a
VALUE type. Since long is < than VALUE on LLP64, the overflow is not
detected. As a result "2**31" evaluates to "-2147483648" on Windows with
gcc-7.1.0.
patched by Lars Kanis lars@greiz-reinsdorf.de

#4

Updated by naruse (Yui NARUSE) over 1 year ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONTNEED

Also available in: Atom PDF