Repository navigation
Conversation
Up to 4.2.3 the initializer of i18n! keeps every entry of all 24 catalogs in one stack frame in an unoptimized build: 1.69 MiB, growing with each key and language. That overflows the 1 MiB main thread of the Windows debug GUI and overlay, and would soon overflow the 2 MiB test threads. 4.2.4 packs each catalog into one literal.
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
|
Tested this on macOS (Apple Silicon) against I've hit the 2 MiB case for real, too. On a fork with a couple hundred more catalog keys, the agent's test threads overflowed in the catalog initializer, which lines up with the estimate in #2686. Might be worth a regression test, so catalog growth or a later rust-i18n change can't quietly bring this back. Here's the one I used. It's a separate integration test target in
|
The first lookup builds the whole catalog on whichever thread asks first, and rust-i18n up to 4.2.3 did that in one stack frame that grows with the catalog (AprilNEA#2686). The test pins that thread to 1 MiB, so catalog growth or a later rust-i18n change cannot bring the overflow back unnoticed. Co-authored-by: Andy Volk <100514+downtempo@users.noreply.github.com>
|
Thanks! Added it with you as co-author (e951ed8). Same on Windows 11: on the full lockfile from before this PR it aborts with |
Summary
Up to 4.2.3, the initializer that
rust_i18n::i18n!generates keeps every entry of all 24 catalogs in one stack frame in an unoptimized build. It is 1.69 MiB on6a2c6fedand grows with every key and language. That overflows the 1 MiB main thread of the Windows debug GUI, and about 170 more keys would overflow the 2 MiB test threads as well (#2686).4.2.4 packs each catalog into one literal (longbridge/rust-i18n#148), so the frame is gone.
Changes
openlogi-agent,openlogi-core,openlogi-desktop,openlogi-overlay: requirerust-i18n4.2.4, so a later lockfile change can't go back below it.Cargo.lock:rust-i18n4.2.1 → 4.2.4, which movesserde-saphyrto 1.3.0 andgranit-parserto 1.3.0. No other package changes version and none is added.Also new since 4.2.1:
locale()caches the current locale per thread and reloads it after eachset_locale(longbridge/rust-i18n#151), so a live language change still reaches every thread.#2126 gives the debug GUI and overlay a larger main-thread stack for the same frame. With this update the debug GUI starts without it. I did not check whether the overlay's ring opens, so whether #2126 is still useful is up to you and its author.
Testing
On Windows 11 (MSVC),
RUSTFLAGS="-D warnings":cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets -- -D warningscargo test --locked --workspacecargo doc --lockedfor the non-GUI crates withRUSTDOCFLAGS="-D warnings"cargo +1.99 check --locked --workspacetypos,ast-grepandcargo-denywere not run locally.The frame and the overflow, before and after:
dumpbinfinds the 1.69 MiB frame in both debug binaries on 4.2.1. On 4.2.4 the largest frame is 0.28 MiB.0xC00000FDon 4.2.1, opens its window on 4.2.4, three starts each.catalog_init_stack(from downtempo) builds the catalog on a 1 MiB thread: it aborts withSTATUS_STACK_OVERFLOWon the lockfile before this PR and passes on 4.2.4.Not runtime-tested on hardware, and not on macOS or Linux.
To test: build
openlogi-desktopin debug on Windows without changing its stack size, and start it.Fixes #2686