Skip to content

runtime: Fix printing failed allocation amounts. #17931

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Aug 15, 2025

Summary

On LP64 and LLP64 systems, size_t is bigger than unsigned. Printing the failed allocation as mp_uint_t allows the correct failed allocation size to be shown. I noticed this in #17925.

However, there are occasions where mp_uint_t is bigger than size_t (nanbox). In that case, preserve the existing code path to avoid growth in executable size.

Example where this affects the failed allocation message (on x86_64 coverage build):

>>> "a" * (1 << 54)

Before, this would print the size as 1. Now it prints it as 18014398509481985 (2**54 + 1).
solve, or what improvement does it add? Add links if relevant. -->

Testing

I built locally and verified that large failed allocations showed the correct value.

Trade-offs and Alternatives

The code ends up more complicated than it was previously, with the hope of avoiding code growth.

I can remove the added size assertions if preferred. I did want to see if the assertions were correct across all builds done by CI.

On LP64 and LLP64 systems, size_t is bigger than unsigned.
Printing the failed allocation as mp_uint_t allows the correct failed
allocation size to be shown.

However, there are occasions where mp_uint_t is bigger than size_t
(nanbox).  In that case, preserve the existing code path to avoid
growth in executable size.

Example where this affects the failed allocation message (on x86_64
coverage build):
```
>>> "a" * (1 << 54)
```

Before, this would print the size as 1.  Now it prints it as
18014398509481985 (2**54 + 1).

Signed-off-by: Jeff Epler <jepler@gmail.com>
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (141f7d0) to head (810dfab).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17931   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22298    22298           
=======================================
  Hits        21939    21939           
  Misses        359      359           

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant