Skip to content

fix(container): the library builds where usize is 32 bits - #346

Merged
DrunkOnJava merged 1 commit into
mainfrom
fix/limits-32-bit
Oct 26, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
fix/limits-32-bit

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

WalkerLimits::permissive().max_scan_bytes and DwgLimits::permissive().max_section_bytes were written as 4 * 1024 * 1024 * 1024 in usize. On a 32-bit target that product overflows, and arithmetic_overflow is deny by default, so checking or building the dwg library itself for wasm32, i686 or armv7 fails. The WASM workflow never caught it: the wasm crate depends on dwg by path, and there a dependency's lint error is only a warning, so wasm-pack build succeeds. The review-fix agent hit it while checking #319's overflow fix on i686.

Both limits now go through saturating_bytes(4 << 30): 4 GiB where it fits, usize::MAX where usize is 32 bits (a 32-bit address space can't hold more anyway). On 64-bit targets the values are unchanged. The Clippy job now also runs cargo check --lib --target wasm32-unknown-unknown, so the regression can't return.

Spec reference

None; portability (src/limits.rs).

Test plan

  • Before: cargo check --lib --target wasm32-unknown-unknown on main fails with "error: this arithmetic operation will overflow --> src/limits.rs:250:29 ... attempt to compute 4194304_usize * 1024_usize"; cd wasm && cargo check --target wasm32-unknown-unknown passes, which hides it.
  • After: cargo check --lib passes for wasm32-unknown-unknown and i686-unknown-linux-musl.
  • cargo clippy --all-targets --all-features -- -D warnings and cargo fmt --check are clean; the existing limits tests pass (12).

Source-provenance declaration

Written for this repository; no external source consulted.

WalkerLimits::permissive and DwgLimits::permissive wrote 4 GiB as a usize
product, which overflows on wasm32, i686 and armv7; arithmetic_overflow is
deny by default, so checking the dwg library itself for any 32-bit target
failed. The wasm crate never saw it, because a lint error in a path
dependency is only a warning. The limit now saturates at usize::MAX there,
and the Clippy job checks the library for wasm32.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 18:36
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T18:38:01.734339Z f2e2cbc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@DrunkOnJava
DrunkOnJava merged commit f7210bf into main Oct 26, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/limits-32-bit branch October 26, 2026 18:50
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