Skip to content

fix(hle): saturate storage quota conversion - #337

Closed
CesarLopesO wants to merge 4 commits into
Marvisak:mainfrom
CesarLopesO:fix/runtime-storage-quota-overflow
Closed

CesarLopesO wants to merge 4 commits into
Marvisak:mainfrom
CesarLopesO:fix/runtime-storage-quota-overflow

Conversation

@CesarLopesO

@CesarLopesO CesarLopesO commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

  • Replace the left shift used to convert the manifest's persistent storage quota from MB to bytes with saturating multiplication.
  • Prevent oversized SizeMB values from silently overflowing during conversion.
  • Add a regression test covering the largest representable MB value and the first value above that limit.

Validation

  • rustfmt --edition 2024 --check crates/victory-hle/src/runtime.rs — passed
  • git diff --check — passed
  • cargo check --locked -p victory-hle --tests --target x86_64-pc-windows-gnu — passed
  • cargo test --locked -p victory-hle --no-run --target x86_64-pc-windows-gnu — passed

Test limitation

cargo test --locked -p victory-hle runtime::tests could not reach the tests on the current Linux main branch because compilation fails first in crates/victory-gpu/src/resource.rs with E0425: cannot find function host_resource.

This is the existing Linux build issue tracked in #90; related Linux compatibility changes are proposed separately in #235. This PR only changes crates/victory-hle/src/runtime.rs.

muhammed-aksoy pushed a commit to muhammed-aksoy/VIctory that referenced this pull request Nov 24, 2026
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremygold02

Copy link
Copy Markdown
Contributor

Tested PR #337 at head 6922a81d615f4e7a55b6f488a0dc704351568a13 (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 6922a81d615f4e7a55b6f488a0dc704351568a13.

  • cargo test --locked -p victory-hle storage_quota_saturates_when_megabytes_exceed_u64_bytes — FAILED (exit 101); detail: error[E0689]: can't call method saturating_mul on ambiguous numeric type {integer} | error: could not compile victory-hle (lib) due to 1 previous error.

Behavior covered: Checks storage quota conversion saturates when megabytes exceed the u64 byte range.
Code: crates/victory-hle/src/runtime.rs

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 6922a81 on Windows 11, RTX 5070, MSVC: victory-hle fails to compile:

error[E0689]: can't call method `saturating_mul` on ambiguous numeric type `{integer}`
   --> crates\victory-hle\src\runtime.rs:104:52
    |
104 |             storage_bytes: storage_mb.unwrap_or(0).saturating_mul(1024 * 1024),

storage_mb.unwrap_or(0) leaves the literal's type undetermined at the point of the method call. Annotate it: storage_mb.unwrap_or(0u64).saturating_mul(1 << 20), or .map_or(0, |mb: u64| mb.saturating_mul(1 << 20)). With that, the saturating conversion and the boundary test look right.

The elements hunk is only rustfmt reflow of an unrelated line. Dropping it would keep the diff focused, especially since #359 also touches that function.

AI-assisted (Claude Code).

@CesarLopesO

Copy link
Copy Markdown
Author

Updated the PR with the explicit u64 parsing fix and the rustfmt adjustments.

Additional validation on Debian 13:

  • rustfmt --edition 2024 --check crates/victory-hle/src/runtime.rs — passed.
  • git diff --check — passed.
  • Windows GNU cross-compilation with cargo check --tests — passed.
  • cargo test --no-run for victory-hle on the Windows GNU target — passed; test binaries were compiled successfully, but not executed.

Native Linux test execution remains blocked by the unrelated host_resource E0425 error in victory-gpu (#90).

Could you please review the updated commit?

nazmi pushed a commit to nazmi/VIctory that referenced this pull request Nov 24, 2026
The manifest's SizeMB was shifted into bytes, which wraps for values at
or above 2^44 instead of saturating, and the parse type was implicit.

Applied as the net patch of upstream PR Marvisak#337 (head
5cf259e), squashing its four commits:
6922a81, f8071b1, c6ffada, 5cf259e. Its first commit alone did not
compile, so the reviewed net diff is what was integrated.

(cherry picked from PR Marvisak#337, source head 5cf259e)

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested 5cf259e on Windows 11, RTX 5070, MSVC: it now compiles, and cargo test -p victory-hle 88 passed, including storage_quota_saturates_when_megabytes_exceed_u64_bytes.

  • This addresses my earlier review (E0689 on an unsuffixed saturating_mul): parse::<u64>() fixes the integer type, so saturating_mul(1024 * 1024) resolves, and a SizeMB above u64::MAX / 2^20 gives u64::MAX instead of wrapping as << 20 did.
  • The test pins both sides of the boundary, the exact limit and one past it.
  • The entity-decoding hunk is a rustfmt reflow only.

AI-assisted (Claude Code).

@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current).

Saturates the SizeMB to bytes conversion, which only matters for a manifest quota above 2^44 MB; cannot occur. The rest is reformatting, and the test was never run (cross-compiled only).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
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.

4 participants