Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ERROR(VpDivd): space for remainder too small" for certain division #220

Closed
grk opened this issue Jan 8, 2022 · 3 comments
Closed

"ERROR(VpDivd): space for remainder too small" for certain division #220

grk opened this issue Jan 8, 2022 · 3 comments
Assignees
Labels

Comments

@grk
Copy link

grk commented Jan 8, 2022

When upgrading to Ruby 3.1, I noticed a crashing edge-case when dividing by a certain number. It does not happen for bigdecimal < 3.1.1, but its 100% reproducible on 3.1.1.

The reproduction code is simple:

BigDecimal('1.0') / BigDecimal('3672577333.6608990499165058135986328125')

Happens on both linux and macos.

irb(main):001:0> BigDecimal::VERSION
=> "3.1.1"
irb(main):002:0> BigDecimal('63.0') / BigDecimal('3672577333.6608990499165058135986328125')
(irb):2: [BUG] ERROR(VpDivd): space for remainder too small.
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0034 p:---- s:0198 e:000197 CFUNC  :/
c:0033 p:0012 s:0193 e:000192 EVAL   (irb):2 [FINISH]
c:0032 p:---- s:0190 e:000189 CFUNC  :eval
c:0031 p:0020 s:0182 e:000181 METHOD /usr/local/lib/ruby/3.0.0/irb/workspace.rb:116
c:0030 p:0059 s:0174 e:000172 METHOD /usr/local/lib/ruby/3.0.0/irb/context.rb:450

Further debug info is I think irrelevant, but I can attach if needed.

@mrkn mrkn self-assigned this Jan 12, 2022
@mrkn mrkn added the bug label Jan 12, 2022
mrkn added a commit that referenced this issue Jan 19, 2022
mrkn added a commit that referenced this issue Jan 19, 2022
@mrkn mrkn closed this as completed in 127a1b5 Jan 19, 2022
@mrkn
Copy link
Member

mrkn commented Jan 19, 2022

@grk Thank you for reporting this!

azrazalea-debtbook added a commit to azrazalea-debtbook/xirr that referenced this issue Sep 8, 2022
estebanz01 added a commit to estebanz01/ruby-statistics that referenced this issue Oct 31, 2022
This change fixes a segmentation error produced by BigDecimal gem on
ruby 3.1.2, where it fails to calculate a big float. It was "fixed"
in BigDecimal 3.1.2, but this version might not be compatible with older
ruby versions.

Reported here: https://bugs.ruby-lang.org/issues/18604 & here: ruby/bigdecimal#220
Potential fix here: ruby/bigdecimal@e236c2e
estebanz01 added a commit to estebanz01/ruby-statistics that referenced this issue Oct 31, 2022
* ci: Run CI on supported stable ruby versions.

* fix: Coerce some denominators to rational when calculating inverse beta.

This change fixes a segmentation error produced by BigDecimal gem on
ruby 3.1.2, where it fails to calculate a big float. It was "fixed"
in BigDecimal 3.1.2, but this version might not be compatible with older
ruby versions.

Reported here: https://bugs.ruby-lang.org/issues/18604 & here: ruby/bigdecimal#220
Potential fix here: ruby/bigdecimal@e236c2e

* spec: Add missing test for BigDecimal and goodness of fit.
@mathieujobin
Copy link

mathieujobin commented Apr 25, 2023

We still encountered this on 3.1.4

irb(main):004:0> comp.send(:pay_per_time_base).class
=> BigDecimal
irb(main):005:0> comp.send(:pay_per_time_base)
=> 0.22e5
irb(main):006:0> comp.send(:hours_per_month)
=> 0.2095999999999999999999999999999999999968e3
irb(main):007:0> comp.send(:hours_per_month).class
=> BigDecimal
irb(main):008:0> comp.send(:pay_per_time_base) / comp.send(:hours_per_month)
(irb):8: [BUG] ERROR(VpDivd): space for remainder too small.
ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]                 
                                                                               
-- Control frame information -----------------------------------------------   
c:0030 p:---- s:0170 e:000169 CFUNC  :/                                        
c:0029 p:0014 s:0165 e:000164 EVAL   (irb):8 [FINISH]                          
c:0028 p:---- s:0162 e:000161 CFUNC  :eval                                     
c:0027 p:0020 s:0154 e:000153 METHOD /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb/workspace.rb:119
c:0026 p:0054 s:0146 e:000144 METHOD /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb/context.rb:476
c:0025 p:0161 s:0137 e:000136 BLOCK  /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb.rb:577
c:0024 p:0024 s:0132 e:000131 METHOD /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb.rb:770
c:0023 p:0007 s:0126 e:000125 BLOCK  /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb.rb:558
c:0022 p:0123 s:0121 e:000120 BLOCK  /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb/ruby-lex.rb:268 [FINISH]
c:0021 p:---- s:0117 e:000116 CFUNC  :loop
c:0020 p:0005 s:0113 e:000112 BLOCK  /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb/ruby-lex.rb:250 [FINISH]
c:0019 p:---- s:0110 e:000109 CFUNC  :catch
c:0018 p:0010 s:0105 e:000104 METHOD /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb/ruby-lex.rb:249
c:0017 p:0047 s:0101 E:000f78 METHOD /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb.rb:557
c:0016 p:0003 s:0096 e:000095 BLOCK  /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb.rb:491 [FINISH]
c:0015 p:---- s:0093 e:000092 CFUNC  :catch
c:0014 p:0057 s:0088 E:0018a0 METHOD /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb.rb:490
c:0013 p:0104 s:0082 e:000081 METHOD /usr/local/rvm/rubies/ruby-3.1.4/lib/ruby/3.1.0/irb.rb:419

@mathieujobin
Copy link

Revisiting this...

Ruby 3.0.6

(BigDecimal('22000.0') / (BigDecimal('9.6') * (BigDecimal('262.0') / BigDecimal(12)))).to_s
=> "104.961832061068702291678806596352193928117233688"

Ruby 3.1.4

BigDecimal('22000.0') / (BigDecimal('9.6') * (BigDecimal('262.0') / BigDecimal(12)))
(pry):4: [BUG] ERROR(VpDivd): space for remainder too small.

Ruby 3.2.2

(BigDecimal('22000.0') / (BigDecimal('9.6') * (BigDecimal('262.0') / BigDecimal(12)))).to_s
=> "104.961832061068702290076335877862595421449798962764407668550783753860497640022134335"

Only 3.1 is affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants