Skip to content

fix int overflow hang in DfpMath.pow for exponents above 2^30 - #346

Merged
aherbert merged 1 commit into
apache:masterfrom
insaf021:dfpmath-pow-exponent-overflow
Nov 3, 2026
Merged

aherbert merged 1 commit into
apache:masterfrom
insaf021:dfpmath-pow-exponent-overflow

Conversation

@insaf021

@insaf021 insaf021 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

DfpMath.pow(Dfp, int) doubles an int trial counter until it exceeds the exponent, so any exponent beyond 2^30 in magnitude (reachable through Dfp.pow(int) and Dfp.scalb(int)) overflows the counter and the inner loop spins forever, and Integer.MIN_VALUE also survives the a = -a negation; carrying the exponent and the counter as long removes both overflows and leaves results for smaller exponents unchanged.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.23%. Comparing base (f554608) to head (5bdce76).
⚠️ Report is 405 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #346      +/-   ##
============================================
+ Coverage     86.54%   87.23%   +0.68%     
+ Complexity     9787       91    -9696     
============================================
  Files           532      499      -33     
  Lines         35516    33531    -1985     
  Branches       6194     5851     -343     
============================================
- Hits          30738    29251    -1487     
+ Misses         3518     3162     -356     
+ Partials       1260     1118     -142     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aherbert
aherbert merged commit bc8a9f3 into apache:master Nov 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants