Issue #13528 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE

ruby_2_4 r59510 merged revision(s) 58523.

----------------------------------------
Bug #13528: Calling #denominator on a whole number floating point number causes segfault with mathn loaded.
https://bugs.ruby-lang.org/issues/13528#change-66028

* Author: burningpony (Russell Osborne)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE
----------------------------------------
Code to reproduce.

~~~ ruby
require "mathn"

(2.0).denominator
~~~

Repeatable in isolated docker container

~~~
docker run -it ruby:slim ruby -e 'require "mathn"; p (2.0).denominator;'
~~~

Stacktrace follows

~~~
-e:1: [BUG] Segmentation fault at 0x0000000000001d
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0003 p:---- s:0011 e:000010 CFUNC  :denominator
c:0002 p:0015 s:0007 e:000005 EVAL   -e:1 [FINISH]
c:0001 p:0000 s:0003 E:002030 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
-e:1:in `<main>'
-e:1:in `denominator'

-- Machine register context ------------------------------------------------
 RIP: 0x00007f9ec9fff185 RBP: 0x0000000000000003 RSP: 0x00007ffcb7f09f30
 RAX: 0x0000000000000005 RBX: 0x0000000000000002 RCX: 0x00007f9eca5c9f50
 RDX: 0x0000000000000001 RDI: 0x0010000000000001 RSI: 0x0000000000000000
  R8: 0x00007f9eca0fcad0  R9: 0x0000000000000002 R10: 0x0000000000000001
 R11: 0x0000000000000001 R12: 0x000000000218fce0 R13: 0x00000000020b0c00
 R14: 0x00000000023e7cf0 R15: 0x0000000000000002 EFL: 0x0000000000010202

-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.2.4(rb_vm_bugreport+0x4f3) [0x7f9eca0c2683] vm_dump.c:684
/usr/local/lib/libruby.so.2.4(rb_bug_context+0xd4) [0x7f9ec9f413a4] error.c:506
/usr/local/lib/libruby.so.2.4(sigsegv+0x3e) [0x7f9eca03605e] signal.c:907
/lib/x86_64-linux-gnu/libpthread.so.0 [0x7f9ec9c8d890]
/usr/local/lib/libruby.so.2.4(float_denominator+0x55) [0x7f9ec9fff185] rational.c:2045
/usr/local/lib/libruby.so.2.4(vm_call_cfunc+0xef) [0x7f9eca0a4f3f] vm_insnhelper.c:1752
/usr/local/lib/libruby.so.2.4(vm_call_method+0xe3) [0x7f9eca0b6b13] vm_insnhelper.c:2292
/usr/local/lib/libruby.so.2.4(vm_exec_core+0x1610) [0x7f9eca0ae3d0] insns.def:1066
/usr/local/lib/libruby.so.2.4(vm_exec+0x8b) [0x7f9eca0b342b] vm.c:1727
/usr/local/lib/libruby.so.2.4(ruby_exec_internal+0xb2) [0x7f9ec9f47132] eval.c:244
/usr/local/lib/libruby.so.2.4(ruby_exec_node+0x1d) [0x7f9ec9f48ead] eval.c:308
/usr/local/lib/libruby.so.2.4(ruby_run_node+0x1e) [0x7f9ec9f4ba6e] eval.c:300
/usr/local/bin/ruby(main+0x4b) [0x40087b] main.c:36

-- Other runtime information -----------------------------------------------

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
    5 /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
    6 /usr/local/lib/ruby/2.4.0/unicode_normalize.rb
    7 /usr/local/lib/ruby/2.4.0/x86_64-linux/rbconfig.rb
    8 /usr/local/lib/ruby/2.4.0/rubygems/compatibility.rb
    9 /usr/local/lib/ruby/2.4.0/rubygems/defaults.rb
   10 /usr/local/lib/ruby/2.4.0/rubygems/deprecate.rb
   11 /usr/local/lib/ruby/2.4.0/rubygems/errors.rb
   12 /usr/local/lib/ruby/2.4.0/rubygems/version.rb
   13 /usr/local/lib/ruby/2.4.0/rubygems/requirement.rb
   14 /usr/local/lib/ruby/2.4.0/rubygems/platform.rb
   15 /usr/local/lib/ruby/2.4.0/rubygems/basic_specification.rb
   16 /usr/local/lib/ruby/2.4.0/rubygems/stub_specification.rb
   17 /usr/local/lib/ruby/2.4.0/rubygems/util/list.rb
   18 /usr/local/lib/ruby/2.4.0/x86_64-linux/stringio.so
   19 /usr/local/lib/ruby/2.4.0/rubygems/specification.rb
   20 /usr/local/lib/ruby/2.4.0/rubygems/exceptions.rb
   21 /usr/local/lib/ruby/2.4.0/rubygems/dependency.rb
   22 /usr/local/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb
   23 /usr/local/lib/ruby/2.4.0/monitor.rb
   24 /usr/local/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb
   25 /usr/local/lib/ruby/2.4.0/rubygems.rb
   26 /usr/local/lib/ruby/2.4.0/rubygems/path_support.rb
   27 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/version.rb
   28 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/core_ext/name_error.rb
   29 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/levenshtein.rb
   30 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/jaro_winkler.rb
   31 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checker.rb
   32 /usr/local/lib/ruby/2.4.0/delegate.rb
   33 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   34 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   35 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb
   36 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/method_name_checker.rb
   37 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/spell_checkers/null_checker.rb
   38 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean/formatter.rb
   39 /usr/local/lib/ruby/gems/2.4.0/gems/did_you_mean-1.1.0/lib/did_you_mean.rb
   40 /usr/local/lib/ruby/2.4.0/cmath.rb
   41 /usr/local/lib/ruby/2.4.0/e2mmap.rb
   42 /usr/local/lib/ruby/2.4.0/matrix.rb
   43 /usr/local/lib/ruby/2.4.0/singleton.rb
   44 /usr/local/lib/ruby/2.4.0/forwardable/impl.rb
   45 /usr/local/lib/ruby/2.4.0/forwardable.rb
   46 /usr/local/lib/ruby/2.4.0/prime.rb
   47 /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/rational.so
   48 /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/complex.so
   49 /usr/local/lib/ruby/2.4.0/mathn.rb

* Process memory map:

00400000-00401000 r-xp 00000000 08:01 1975189                            /usr/local/bin/ruby
00600000-00601000 rw-p 00000000 08:01 1975189                            /usr/local/bin/ruby
02085000-0245e000 rw-p 00000000 00:00 0                                  [heap]
7f9ec74ce000-7f9ec7677000 r--s 00000000 08:01 543243                     /lib/x86_64-linux-gnu/libc-2.19.so
7f9ec7677000-7f9ec8572000 r--s 00000000 08:01 1975226                    /usr/local/lib/libruby.so.2.4.1
7f9ec8572000-7f9ec8588000 r-xp 00000000 08:01 543262                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f9ec8588000-7f9ec8787000 ---p 00016000 08:01 543262                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f9ec8787000-7f9ec8788000 rw-p 00015000 08:01 543262                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7f9ec8788000-7f9ec8789000 r-xp 00000000 08:01 2101319                    /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/complex.so
7f9ec8789000-7f9ec8988000 ---p 00001000 08:01 2101319                    /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/complex.so
7f9ec8988000-7f9ec8989000 rw-p 00000000 08:01 2101319                    /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/complex.so
7f9ec8989000-7f9ec898a000 r-xp 00000000 08:01 2101320                    /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/rational.so
7f9ec898a000-7f9ec8b89000 ---p 00001000 08:01 2101320                    /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/rational.so
7f9ec8b89000-7f9ec8b8a000 rw-p 00000000 08:01 2101320                    /usr/local/lib/ruby/2.4.0/x86_64-linux/mathn/rational.so
7f9ec8b8a000-7f9ec8b92000 r-xp 00000000 08:01 2101336                    /usr/local/lib/ruby/2.4.0/x86_64-linux/stringio.so
7f9ec8b92000-7f9ec8d91000 ---p 00008000 08:01 2101336                    /usr/local/lib/ruby/2.4.0/x86_64-linux/stringio.so
7f9ec8d91000-7f9ec8d92000 rw-p 00007000 08:01 2101336                    /usr/local/lib/ruby/2.4.0/x86_64-linux/stringio.so
7f9ec8d92000-7f9ec8d95000 r-xp 00000000 08:01 2101291                    /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
7f9ec8d95000-7f9ec8f94000 ---p 00003000 08:01 2101291                    /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
7f9ec8f94000-7f9ec8f95000 rw-p 00002000 08:01 2101291                    /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/trans/transdb.so
7f9ec8f95000-7f9ec8f97000 r-xp 00000000 08:01 2101248                    /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
7f9ec8f97000-7f9ec9196000 ---p 00002000 08:01 2101248                    /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
7f9ec9196000-7f9ec9197000 rw-p 00001000 08:01 2101248                    /usr/local/lib/ruby/2.4.0/x86_64-linux/enc/encdb.so
7f9ec9197000-7f9ec9338000 r-xp 00000000 08:01 543243                     /lib/x86_64-linux-gnu/libc-2.19.so
7f9ec9338000-7f9ec9538000 ---p 001a1000 08:01 543243                     /lib/x86_64-linux-gnu/libc-2.19.so
7f9ec9538000-7f9ec953c000 r--p 001a1000 08:01 543243                     /lib/x86_64-linux-gnu/libc-2.19.so
7f9ec953c000-7f9ec953e000 rw-p 001a5000 08:01 543243                     /lib/x86_64-linux-gnu/libc-2.19.so
7f9ec953e000-7f9ec9542000 rw-p 00000000 00:00 0
7f9ec9542000-7f9ec9642000 r-xp 00000000 08:01 543273                     /lib/x86_64-linux-gnu/libm-2.19.so
7f9ec9642000-7f9ec9841000 ---p 00100000 08:01 543273                     /lib/x86_64-linux-gnu/libm-2.19.so
7f9ec9841000-7f9ec9842000 r--p 000ff000 08:01 543273                     /lib/x86_64-linux-gnu/libm-2.19.so
7f9ec9842000-7f9ec9843000 rw-p 00100000 08:01 543273                     /lib/x86_64-linux-gnu/libm-2.19.so
7f9ec9843000-7f9ec984b000 r-xp 00000000 08:01 543251                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f9ec984b000-7f9ec9a4a000 ---p 00008000 08:01 543251                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f9ec9a4a000-7f9ec9a4b000 r--p 00007000 08:01 543251                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f9ec9a4b000-7f9ec9a4c000 rw-p 00008000 08:01 543251                     /lib/x86_64-linux-gnu/libcrypt-2.19.so
7f9ec9a4c000-7f9ec9a7a000 rw-p 00000000 00:00 0
7f9ec9a7a000-7f9ec9a7d000 r-xp 00000000 08:01 543256                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f9ec9a7d000-7f9ec9c7c000 ---p 00003000 08:01 543256                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f9ec9c7c000-7f9ec9c7d000 r--p 00002000 08:01 543256                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f9ec9c7d000-7f9ec9c7e000 rw-p 00003000 08:01 543256                     /lib/x86_64-linux-gnu/libdl-2.19.so
7f9ec9c7e000-7f9ec9c96000 r-xp 00000000 08:01 543307                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f9ec9c96000-7f9ec9e95000 ---p 00018000 08:01 543307                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f9ec9e95000-7f9ec9e96000 r--p 00017000 08:01 543307                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f9ec9e96000-7f9ec9e97000 rw-p 00018000 08:01 543307                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f9ec9e97000-7f9ec9e9b000 rw-p 00000000 00:00 0
7f9ec9e9b000-7f9eca19c000 r-xp 00000000 08:01 1975226                    /usr/local/lib/libruby.so.2.4.1
7f9eca19c000-7f9eca39b000 ---p 00301000 08:01 1975226                    /usr/local/lib/libruby.so.2.4.1
7f9eca39b000-7f9eca3a4000 rw-p 00300000 08:01 1975226                    /usr/local/lib/libruby.so.2.4.1
7f9eca3a4000-7f9eca3b5000 rw-p 00000000 00:00 0
7f9eca3b5000-7f9eca3d5000 r-xp 00000000 08:01 543225                     /lib/x86_64-linux-gnu/ld-2.19.so
7f9eca44f000-7f9eca471000 r--s 00000000 08:01 543307                     /lib/x86_64-linux-gnu/libpthread-2.19.so
7f9eca471000-7f9eca495000 r--s 00000000 08:01 1975189                    /usr/local/bin/ruby
7f9eca495000-7f9eca4c6000 rw-p 00000000 00:00 0
7f9eca4c6000-7f9eca4c7000 ---p 00000000 00:00 0
7f9eca4c7000-7f9eca5d0000 rw-p 00000000 00:00 0
7f9eca5d2000-7f9eca5d5000 rw-p 00000000 00:00 0
7f9eca5d5000-7f9eca5d6000 r--p 00020000 08:01 543225                     /lib/x86_64-linux-gnu/ld-2.19.so
7f9eca5d6000-7f9eca5d7000 rw-p 00021000 08:01 543225                     /lib/x86_64-linux-gnu/ld-2.19.so
7f9eca5d7000-7f9eca5d8000 rw-p 00000000 00:00 0
7ffcb770c000-7ffcb7f0b000 rw-p 00000000 00:00 0                          [stack]
7ffcb7f44000-7ffcb7f46000 r--p 00000000 00:00 0                          [vvar]
7ffcb7f46000-7ffcb7f48000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
~~~




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>