Bug #8924

mathn/rational causes segmentation fault when calling :round on a Rational

Added by Benjamin Fleischer 7 months ago. Updated 7 months ago.

[ruby-core:57274]
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

Description

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")

coveredpercent.round(2) # => (20/1)
require 'mathn/rational'
covered
percent.round(2) # => segfault

Partial output:

/var/lib/jenkins/workspace/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/testreporter/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/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/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/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/test
c:0008 p:0046 s:0028 b:0028 l:000027 d:000027 METHOD /var/lib/jenkins/workspace/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/test
c:0007 p:0030 s:0020 b:0020 l:000019 d:000019 METHOD /var/lib/jenkins/workspace/Projectmaster/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

crashlog.txt Magnifier (402 KB) Benjamin Fleischer, 09/19/2013 01:45 PM


Related issues

Duplicates ruby-trunk - Bug #8687: mathn and round causes an segmentationfault Closed 07/26/2013

History

#1 Updated by David MacMahon 7 months ago

There was another issue recently where requiring "mathn/rational" by itself caused problems that did not occur when requiring "mathn" in its entirety.

Does the problem still occur if you "require 'mathn'" instead of "require 'mathn/rational'"?

Dave

On Sep 18, 2013, at 9:45 PM, bf4 (Benjamin Fleischer) wrote:

Issue #8924 has been reported by bf4 (Benjamin Fleischer).


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

Author: bf4 (Benjamin Fleischer)
Status: Open
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: UNKNOWN, 2.0.0: UNKNOWN

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")

coveredpercent.round(2) # => (20/1)
require 'mathn/rational'
covered
percent.round(2) # => segfault

Partial output:

/var/lib/jenkins/workspace/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/testreporter/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/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/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/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/test
c:0008 p:0046 s:0028 b:0028 l:000027 d:000027 METHOD /var/lib/jenkins/workspace/Projectmaster/vendor/bundle/ruby/1.9.1/gems/codeclimate-test-reporter-0.0.7/lib/codeclimate/test
c:0007 p:0030 s:0020 b:0020 l:000019 d:000019 METHOD /var/lib/jenkins/workspace/Projectmaster/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

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

#2 Updated by Nobuyoshi Nakada 7 months ago

  • 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

#3 Updated by Benjamin Fleischer 7 months ago

david_macmahon (David MacMahon) wrote:

There was another issue recently where requiring "mathn/rational" by itself caused problems that did not occur when requiring "mathn" in its entirety.

Does the problem still occur if you "require 'mathn'" instead of "require 'mathn/rational'"?

Yes.

Thanks @nobu for pointing me to the related issue with the fix. https://bugs.ruby-lang.org/issues/8687 I searched but didn't find it.

Also available in: Atom PDF