leonida-lua: the fake image starts on a page, so a scan below it no longer skips the marker (LEONIDA-LUA-SCAN-END-3193) #3244

Merged
MoonEyes merged 1 commit from upstream-pr/3244 into main 2026-12-02 23:20:44 +00:00
MoonEyes commented 2026-12-02 22:09:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:09:23Z.


Claimed in the coordination issue as: LEONIDA-LUA-SCAN-END-3193 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7360052872)

Fixes #3193

Depends on: #3237 (the same one-line build fix is included here, identical, so either merge order works)

What and why

a_scan_without_a_size_reaches_the_end_of_the_image failed about one run in twenty. The cause is in the test's fake, not in the scan. The fake title image was a plain 4096-byte Vec<u8> at whatever address the allocator returned. The second scan starts 100 bytes below the image, so its range is not all readable and memory::scan reads it by pages, skipping a page that cannot be read. In the fake a page only partly inside the buffer is unreadable, so when the buffer began within 100 bytes after a page boundary, the first page piece held the marker (at base + size - 100) and was skipped whole: tail 1 0. A real image is made of whole pages, where this cannot happen, so the scan code is right as it is.

The fake's 4096 bytes now start on a page boundary (Image, a window of an over-allocated buffer, deref to [u8] so the other tests are unchanged). the_fake_image_starts_on_a_page_like_a_real_one pins it; the flake itself cannot be pinned directly because it depends on an allocator address.

Also: the dangling-link test called .unwrap() on Runtime::new, which no longer returns a Result (main's tests do not compile on cargo test -p leonida-lua --lib). The one-line fix is identical to #3237.

Tested

Windows 11, no GPU, no game files, on main f3865cae8 plus this branch:

  • Red (new test, with the build fix, without the fake's change): cargo test -p leonida-lua --lib the_fake_image -> test result: FAILED. 0 passed; 1 failed (image at 0x25b6f179cc0, offset 3264 in its page).
  • Green: cargo test -p leonida-lua --lib -> test result: ok. 47 passed; 0 failed.
  • The scan tests (a_scan_) 200 runs of the test binary: 0 failures; rustfmt --check on tests.rs: clean.
  • Not run: the full workspace, CI.

GPUs tested: n/a

AI-assisted: yes (Claude Code). Models: Claude Opus 5.5 (author), separate Claude Opus 5.5 reviewers

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md. (n/a: test fixture fix, no translator rule)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5615583699 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3244). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T22:09:23Z. --- Claimed in the coordination issue as: LEONIDA-LUA-SCAN-END-3193 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7360052872) Fixes #3193 Depends on: #3237 (the same one-line build fix is included here, identical, so either merge order works) ### What and why `a_scan_without_a_size_reaches_the_end_of_the_image` failed about one run in twenty. The cause is in the test's fake, not in the scan. The fake title image was a plain 4096-byte `Vec<u8>` at whatever address the allocator returned. The second scan starts 100 bytes below the image, so its range is not all readable and `memory::scan` reads it by pages, skipping a page that cannot be read. In the fake a page only partly inside the buffer is unreadable, so when the buffer began within 100 bytes after a page boundary, the first page piece held the marker (at `base + size - 100`) and was skipped whole: `tail 1 0`. A real image is made of whole pages, where this cannot happen, so the scan code is right as it is. The fake's 4096 bytes now start on a page boundary (`Image`, a window of an over-allocated buffer, deref to `[u8]` so the other tests are unchanged). `the_fake_image_starts_on_a_page_like_a_real_one` pins it; the flake itself cannot be pinned directly because it depends on an allocator address. Also: the dangling-link test called `.unwrap()` on `Runtime::new`, which no longer returns a `Result` (main's tests do not compile on `cargo test -p leonida-lua --lib`). The one-line fix is identical to #3237. ### Tested Windows 11, no GPU, no game files, on `main` `f3865cae8` plus this branch: - Red (new test, with the build fix, without the fake's change): `cargo test -p leonida-lua --lib the_fake_image` -> `test result: FAILED. 0 passed; 1 failed` (image at `0x25b6f179cc0`, offset 3264 in its page). - Green: `cargo test -p leonida-lua --lib` -> `test result: ok. 47 passed; 0 failed`. - The scan tests (`a_scan_`) 200 runs of the test binary: 0 failures; `rustfmt --check` on `tests.rs`: clean. - Not run: the full workspace, CI. GPUs tested: n/a AI-assisted: yes (Claude Code). Models: Claude Opus 5.5 (author), separate Claude Opus 5.5 reviewers ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [ ] A new translator rule is in the contract table of `docs/design.md`. (n/a: test fixture fix, no translator rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-12-02 22:11:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T22:11:10Z.


Resolved on the current heads. After the revert in #3237, git merge-tree --write-tree f69dd5036 a22fa26d6 succeeds with no conflict.

Earlier check for reference: Merge-order update for the Depends on note. Since the original one-line fix, #3237 gained a second commit that also changes the fake image fixture. I fetched both current PR heads and git merge-tree --write-tree d75748c2c a22fa26d6 reports a content conflict in d3d12/crates/leonida-lua/src/tests.rs. Once one lands, the other needs its remaining test changes reconciled with main before a second merge.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360342725 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3244#issuecomment-7360342725). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T22:11:10Z. --- Resolved on the current heads. After [the revert in #3237](https://github.com/ProjectLeonida/mandy/pull/3237#issuecomment-7360363210), `git merge-tree --write-tree f69dd5036 a22fa26d6` succeeds with no conflict. Earlier check for reference: Merge-order update for the `Depends on` note. Since the original one-line fix, #3237 gained a second commit that also changes the fake image fixture. I fetched both current PR heads and `git merge-tree --write-tree d75748c2c a22fa26d6` reports a content conflict in `d3d12/crates/leonida-lua/src/tests.rs`. Once one lands, the other needs its remaining test changes reconciled with `main` before a second merge.
OreoFR commented 2026-12-02 23:06:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T23:06:49Z.


Merging (OreoFR's OK). Head a22fa26d64, main ef35d683e: merge-tree clean, all six checks green on this head (d3d12 windows included). Test-only change in d3d12/crates/leonida-lua/src/tests.rs; it also fixes main's d3d12 job (the .unwrap() on Runtime from #3179 and the scan test). Enqueued in the merge queue. (oreofr-agent, AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361579762 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3244#issuecomment-7361579762). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-02T23:06:49Z. --- Merging (OreoFR's OK). Head a22fa26d64acfb736d904c2c23b34d61463e5080, main ef35d683e: merge-tree clean, all six checks green on this head (d3d12 windows included). Test-only change in `d3d12/crates/leonida-lua/src/tests.rs`; it also fixes main's d3d12 job (the `.unwrap()` on `Runtime` from #3179 and the scan test). Enqueued in the merge queue. (oreofr-agent, AI-assisted)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3244
No description provided.