test(host): the control bridge's memory bound is run on a region's edges #3010
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3010
Loading…
Reference in a new issue
No description provided.
Delete branch "PedroRossi/Longshot:test/hos-mem-region-bounds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Nothing fails if the control bridge's memory bound breaks. With
HOS_CONTROL_MEMon, the control bridge (thelocal socket tools drive the game through) reads and writes the game's memory for its client, and
hos_mem_region(
host/hos_mem.c) is the one check that keeps those ranges inside it: a range it wrongly accepts reaches memoryoutside the guest. No test runs it:
tests/control_test.clinksfake_mem_regionin its place, and none of the teststhat build the real
hos_mem.cnotices it broken. On main @1938a302, with its region end check or its empty-range checktaken out, each of them gives the same result as before.
This adds checks to
tests/test_host_free_marks.py, which already builds the realhos_mem.c: on the lower of tworegions (so the end of the window doesn't catch a range for it), a range across the region's end, an empty range, one
that wraps past 2^64, and one in the region once it is freed. They fail with either check removed. A test only.
Testing
Tested: on this PC (Linux): the new checks pass, and fail with the end check removed and with the
empty-range check removed. On main, those two removals change no test's result (test_host_free_marks.py,
test_host_guest_writes.py, test_libc_hooks.py and test_vk_collect_window.py pass either way; test_vcore_region_free.py
fails either way, as on main).
mise run test(--strict) on main @1938a302, and on main with this change merged (together with #3009, #3011, #3012, #3013, #3014, from the same audit): 775 passed, 145 failed, 10 skipped both ways, so none fails only with it. The 145 are named at the end.Still to test:
None: a test, run here.
Measurements
Nothing to measure: a test; the game's code doesn't change.
Risks
None: a test.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.The 145 checks of
mise run testthat fail on main @1938a302on this PC too, with or without this change97 need a tool this PC doesn't have on PATH (
--strictfails them):48 fail on main itself: test_blocks_at_start.py, test_bug_report.py, test_cloth_kernels.py, test_cloth_loops.py, test_cloth_sphere.py, test_cloth_step12.py, test_cloth_step8.py, test_cloth_step9.py, test_control_picture.py, test_crash_record.py, test_crt_options.py, test_dev_update.py, test_dlssg_pace.py, test_draw_stream_visibility.py, test_framegen_resources.py, test_fsr_uniform_ownership.py, test_game_boundary.py, test_guest_holes.py, test_image_reaper_threads.py, test_image_view_retry.py, test_input_background.py, test_keyboard_option.py, test_linux_pressure.py, test_loaded_modules_drop.py, test_log_levels.py, test_menu_keys.py, test_menu_save_atomic.py, test_mesh_first_types.py, test_oot_occ_raster.py, test_option_ids.py, test_perf_send.py, test_pipeline_tour.py, test_present_acquire_ahead.py, test_present_image_free.py, test_present_source_crop.py, test_program_cache_cleanup.py, test_program_cache_one_variant.py, test_readback_timeout_reuse.py, test_recording_admission.py, test_screensaver.py, test_switch_table.py, test_target_retention.py, test_tex_desc_memo.py, test_thinlto_tls.py, test_upscaler_round_trip.py, test_vram_compact.py, test_windows_display_startup.py, test_windows_on_linux.py
Found in an AI-assisted audit of the repository. The test, the fix, the runs and this description were made with Claude Code; I reviewed them.
Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
WIP: test(host): the control bridge's memory bound is run on a region's edgesto test(host): the control bridge's memory bound is run on a region's edges@review
Recommendation: Approve. The new assertions cover the stated region-end and empty-range cases, and the author reports that each catches its corresponding removed check. CI is still running, and the test inherits a compiler selection that can skip the new coverage on supported setups. Nothing blocking is left. Recommend approval; not approved on the forge.
Adds game-free checks for address-region boundaries, empty and wrapping ranges, and freed regions. It improves regression coverage without changing player code, but ties that coverage to a test harness that hard-codes GCC.
Should fix (1): not blocking, but worth doing before merging.
tests/test_host_free_marks.py:218: The new checks inherit a harness that hard-codes GCC instead of honoring the selected C compiler. (more on the line) Do: Use the test runner's {cc} compiler selection and honor CC for direct invocation, while retaining an explicit --cc override.@fixcan do L1.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes: the author reports that the new checks pass and fail when either the region-end check or the empty-range check is removed. This is not a performance change.
Other systems: The changed assertions run only in a test fixture; they do not change the game, renderer, saves, input, audio, or build. The fixture has Windows-specific paths, but the reported run was on Linux and its runner requires GCC.
Switches: None added, changed, or removed.
Reviewed:
1064bba4c2against1938a302fe: Read AGENTS.md, CONTRIBUTING.md, the pull request template, docs/dev/standards.md, the full changed test, host/hos_mem.c, its guest-range helper, and the control bridge's memory-service callers. Read the full diff and commit; skimmed test-runner compiler selection and CI workflow references. docs/review-checklist.md and the adjacent Tooling checkout were absent. No recorded runs or generated files were changed.; nothing run (a code review).Checked and fine:
Testing: No commands from the project, builds, or tests were run, as requested. The author's Linux results are reported in the pull request; CI remains in progress.
Overlaps and merge order: Not checked; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -211,0 +215,4 @@/* hos_mem_region, the control bridge's one bound on what its memory reads and writes reach: a range wholly in oneregion answers that region's class; one a byte past its end, one of no bytes, one that wraps past 2^64 and afreed region answer none *//* (two regions: the lower one's end is inside the window, so the window's own bound can't answer for it) */L1 (should fix): The new checks inherit a harness that hard-codes GCC instead of honoring the selected C compiler.
When: On a supported Windows or Linux development setup with clang available through CC but no gcc on PATH, run_all.py skips this test, or fails it in strict mode, so these new boundary checks never run.
Do: Use the test runner's {cc} compiler selection and honor CC for direct invocation, while retaining an explicit --cc override.