Project

General

Profile

Actions

Bug #13748

closed

[PATCH] Fix mul overflow detection for LLP64 arch.

Added by larskanis (Lars Kanis) over 7 years ago. Updated about 7 years ago.

Status:
Closed
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

Updated by MSP-Greg (Greg L) over 7 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.

Actions #2

Updated by larskanis (Lars Kanis) over 7 years ago

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

Updated by naruse (Yui NARUSE) about 7 years 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

Actions #4

Updated by naruse (Yui NARUSE) about 7 years ago

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0