1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/internal
Jeremy Evans fe6245b430 Fix rb_fix_mul_fix on OpenBSD/mips64
This fixes invalid and inconsistent results for the Fixnum*Fixnum case
where the result of the multiplication does not fit in 64-bit
on OpenBSD/mips64.  For example:

  $  for x in 1 23; do ruby31 -e 'p(54306000000000*86400)'; done
  14409380628474329524
  11410664325873689790

Cases where an argument was Bignum, as well as cases where the result
of the multiplication fits in 64-bit are fine:

  $ for x in 1 23; do ruby31 -e 'p(54306000*86400)'; done
  4692038400000
  4692038400000

  $ for x in 1 23; do ruby31 -e 'p(5430600000000000000000*86400)'; done
  469203840000000000000000000
  469203840000000000000000000

This was originally discovered by running the tests for the openssl gem
on OpenBSD/mips64 and having one test fail for a date far in the future.
I eventually traced this to the generic multiplication issue.

The underlying cause is using the int128_t type. This avoids use of the
int128_t type in this case, falling back to the slower conversion code,
which in the overflow case, turns the Fixnums into Bignums, then
performs the multiplication.
2022-07-03 09:42:44 -07:00
..
array.h
bignum.h
bits.h
class.h
cmdlineopt.h
compar.h
compile.h
compilers.h
complex.h
cont.h
dir.h
enc.h
encoding.h
enum.h
enumerator.h
error.h
eval.h
file.h
fixnum.h Fix rb_fix_mul_fix on OpenBSD/mips64 2022-07-03 09:42:44 -07:00
gc.h
hash.h
imemo.h
inits.h
io.h
load.h
loadpath.h
math.h
missing.h
numeric.h
object.h Allow to just warn as bool expected, without an exception 2022-06-20 19:35:12 +09:00
parse.h
proc.h
process.h
ractor.h
random.h
range.h
rational.h
re.h
sanitizers.h
serial.h
signal.h
static_assert.h
string.h
struct.h
symbol.h
thread.h Restore rb_exec_recursive_outer 2022-06-15 16:07:29 -07:00
time.h
transcode.h
util.h
variable.h
vm.h
warnings.h