Skip to content

fix(format): the base-conversion chunk is bounded by bigint's limb base, tested by division - #230

Merged
jonruttan merged 2 commits into
mainfrom
fix/chunk-bound-by-word
Nov 5, 2026
Merged

jonruttan merged 2 commits into
mainfrom
fix/chunk-bound-by-word

Conversation

@jonruttan

@jonruttan jonruttan commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What

%py-fmt-chunk-of found the largest base^k under 10^9 by multiplying until the product reached it. On a 4-byte word 16^8 is 2^32, which multiplies to zero, and a zero never reaches a bound: loading the bundle allocated until the machine refused. That is why no state image and no Python ran on 32-bit arm (jonruttan/x-os#85's armv7 leg; 4.19 GB on a Raspberry Pi 4, then exit 2).

The bound is now bigint's own limb base, bigint-base, sized to the word (10^9 on an 8-byte word, 10^4 on a 4-byte one), so a chunk stays inside one limb on either; and it is tested by division, which cannot wrap. On 64-bit the chunks are what they were.

The chunks are made at first use, not when format.x loads. bigint-base reaches python/core through runtime-num.x, which loads after format.x; a top-level import of x/num/bigint from format.x changed the load order and broke integer reading on the Pi.

Verified

  • 64-bit (this Mac, x-lang v0.46.0): 31-format and 58-floordiv-bigints, 21 tests, 0 failed.
  • 32-bit (Raspberry Pi 4, 32-bit Raspbian, x-lang feat/linux-arm): the bundle loads at a 1.07 GB peak, where it reached 4.19 GB inside format.x and died before. Python boots from source: print(1+1) prints 2, and hex(2**70), oct(2**70) print 0x400000000000000000 0o200000000000000000000000.
  • What the Pi shows next is not this change's: the float decoders (%py-f-exact, python-ieee-raw) read the payload as one integer, but on a 4-byte word it is two words. 13 of the 21 cases fail with no < for VECTOR for that, and one 58-floordiv-bigints batch segfaults.

🤖 Generated with Claude Code

jonruttan and others added 2 commits November 5, 2026 15:28
…se, tested by division

%py-fmt-chunk-of looked for the largest base^k under 10^9 by multiplying
until the product reached it.  On a 4-byte word 16^8 is 2^32, which
multiplies to zero, and a zero never reaches a bound: loading the bundle
allocated until the machine refused, which is why no state image and no
Python ran on 32-bit arm (4.19 GB on a Raspberry Pi 4, then exit 2).

The bound is bigint's own limb base, sized to the word (10^9 on an
8-byte word, 10^4 on a 4-byte one), so a chunk stays inside one limb on
either, and it is tested by division, which cannot wrap.  On 64-bit the
chunks are what they were; on the Pi the load now peaks at 1.07 GB.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Importing bigint at the top of format.x moved it ahead of the compile
ladder and python's tokenizer registrations, and on a 4-byte word that
order left every integer literal reading as a symbol while bigint.x
itself loaded.  bigint-base is runtime-num.x's import into this module,
bound by the time a program formats and not before; the three chunks are
made then, and nothing about the load moves.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jonruttan
jonruttan merged commit 360f066 into main Nov 5, 2026
12 checks passed
@jonruttan
jonruttan deleted the fix/chunk-bound-by-word branch November 10, 2026 17:39
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