Issue #8924 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Open to Closed
Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: DONTNEED


----------------------------------------
Bug #8924: mathn/rational causes segmentation fault when calling :round on a Rational
https://bugs.ruby-lang.org/issues/8924#change-41892

Author: bf4 (Benjamin Fleischer)
Status: Closed
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin10.8.0]
Backport: 1.9.3: DONTNEED, 2.0.0: DONTNEED


Summary: Confirmed for MRI 1.9/2.0 various patchlevels, on OS X Snow Leopard.

To reproduce:

covered_percent = Marshal.load("\x04\bU:\rRational[\ai\x01\xC8i\x0F")
# or require 'yaml'; covered_percent = YAML.load("--- !ruby/object:Rational\ndenominator: 10\nnumerator: 200\n")
covered_percent.round(2) # => (20/1)
require 'mathn/rational'
covered_percent.round(2) # => segfault

Partial output:

/var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test_reporter/formatter.rb:50: [BUG] Segmentation fault
ruby 1.9.3p362 (2012-12-25 revision 38607) [x86_64-linux]
 
-- Control frame information -----------------------------------------------
c:0013 p:---- s:0055 b:0055 l:000054 d:000054 CFUNC  :round
c:0012 p:0198 s:0051 b:0042 l:000033 d:000041 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0011 p:---- s:0039 b:0039 l:000038 d:000038 FINISH
c:0010 p:---- s:0037 b:0037 l:000036 d:000036 CFUNC  :map
c:0009 p:0037 s:0034 b:0034 l:000033 d:000033 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0008 p:0046 s:0028 b:0028 l:000027 d:000027 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/code_climate/test
c:0007 p:0030 s:0020 b:0020 l:000019 d:000019 METHOD /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/result.rb:91
c:0006 p:0021 s:0017 b:0017 l:001d00 d:000016 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/configuration.rb:133
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 FINISH
c:0004 p:---- s:0013 b:0013 l:000012 d:000012 CFUNC  :call
c:0003 p:0070 s:0010 b:0010 l:0025e0 d:000009 BLOCK  /var/lib/jenkins/workspace/Project_master/vendor/bundle/ruby/1.9.1/gems/simplecov-0.7.1/lib/simplecov/defaults.rb:52
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001618 d:001618 TOP

- Related reports: 
  - https://github.com/codeclimate/ruby-test-reporter/pull/15#issuecomment-24715035
- Crash output: attached and at url: https://gist.github.com/bf4/c2f663c9023bb4eaa83c)


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