fix(sandbox): Windows: a sandboxed start with a profile reaches play, its saves and the test mode's results written #2726
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2726
Loading…
Reference in a new issue
No description provided.
Delete branch "ChloeNow/Longshot:fix/sandbox-profile-start"
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?
fix(sandbox): Windows: a sandboxed start with a profile reaches play, its saves and the test mode's results written
Summary
On Windows, a game the builder confines with a launcher profile (
LONGSHOT_PROFILE, as everydev.py game-testsrunhas) quits before the title. Three things stop it in turn, each hidden behind the one before; this fixes all three, so
a sandboxed test run reaches play and writes its results.
host/hos_main.c). The early choice runs beforehos_sandbox_startinstalls the file layer, so inside the container the profile's saves folder "could not be made".Inside the container it is now chosen after (
nn_fs.ckeeps its first choice); outside it, as before.build_core::files_windows, error 5). The builder's file service checks what itopened (
opened_ok's link check,is_dir) by reading the handle's attributes. A write-only request(
GENERIC_WRITE:fopen "w", the save folder's write test) has no right to them, so the handle read as a link andwas refused: "the save folder can't be used: the game cannot write there". The open is now made with
FILE_READ_ATTRIBUTEStoo, and the game's copy carries it; a folder made is opened with it for the same check.build_core::sandbox_windows).HOS_MOD_TESTS_OUT, where the gamewrites
results.jsonandjunit.xml(dev.py game-tests names one outside the game folder), is now written andmade first.
host/save_dir.h: the save folder's write test says Windows' error, opening or writing; that error named thesecond cause above.
This ports #2726's earlier version (written for the old game-side broker) to the builder-confined design on the
squashed
mod-api.On mod-api, to see it: Windows, sandboxed (the default):
dev.py game-testsof any mod. The game quits with "thesave folder can't be used: the profile's saves folder ...: the folder could not be made".
Read first: the Windows start in
host/hos_main.c, thenfiles_windows.rs' open (op 1).Testing
Tested: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24.
tests/test_sandbox_save_dir_early.py: the Windows start andnn_fs.c's choice, cut from the source, with stand-ins.On mod-api it fails with "a confined start with a profile refuses its save folder: inside 0 1 the profile's saves
folder C:\p\saves: the folder could not be made". Here it passes.
build-corefiles_windows::tests::the_cache_takes_files_folders_renames_and_removes(mod-api's own; nativeWindows): on mod-api it fails at its first write-only open. Here it passes, with the other four.
build-coresandbox_windows::gather::tests::the_test_mode_s_results_folder_is_given_written(new):plan_foron agame in a temporary folder with
HOS_MOD_TESTS_OUTset. On mod-api it fails with "HOS_MOD_TESTS_OUT (...) written:grants [...], roots [...]". Here it passes, with the rest of
sandbox_windows(28).dev.py game-testsof a probe mod, sandboxed, headless, with the builder confining the game. Thebranch was merged locally with #2747 and #2745 (the probe's folder and call); that merge was not pushed. On
mod-api: "the folder could not be made", then (with the first fix alone) "the game cannot write there (Windows error
5 opening a file in it)". Here: the game reaches play, the test passes, and
results.jsonis written: 1 passed,exit 0.
Still to test:
dev.py game-testsof any mod (the builder's Linux plan,sandbox_linux.rs, may lack theresults folder too: not changed here, as it can't be built on Windows).
The 118 checks that fail on Windows on mod-api (`
eaf4a48b9`) tootest_antilag.py,test_astc_decoder_gpu.py,test_async_safe_frees.py,test_audio_output_devices.py,test_audio_source_load.py,test_auto_handheld.py,test_bc_copy_layer_pitch.py,test_builder_channel.py,test_builtin_compute_unoptimized.py,test_capture_dimensions.py,test_capture_readback_visibility.py,test_capture_resources.py,test_coopmat_probe_failures.py,test_crash_record.py,test_desc_counts.py,test_dev_ab.py,test_dev_build.py,test_dev_migrate.py,test_dev_packs.py,test_dev_update.py,test_device_policy.py,test_draw_binds.py,test_draw_stream_visibility.py,test_drs.py,test_dummy_views.py,test_dump_readback.py,test_fallback_pipeline_state.py,test_float_add_subgroup.py,test_framegen_resources.py,test_framelog_sink.py,test_fsr3_release_frees.py,test_fsr3fi_hud_mask.py,test_fsr4_bind_dispatch.py,test_fsr4_tune.py,test_fsr_image_retirement.py,test_fsr_uniform_ownership.py,test_game_menu_mouse_buttons.py,test_gcn_mesh_shared_warp.py,test_image_view_retry.py,test_import_buffer_binding.py,test_import_log.py,test_import_reach.py,test_inline_write_order.py,test_input_background.py,test_input_movie.py,test_job_queue.py,test_lifter.py,test_linux_pressure.py,test_loaded_modules_drop.py,test_longshot_builder.py,test_longshot_ctl.py,test_lost_wait_said.py,test_low_vram_texture_mips.py,test_menu_hooks.py,test_mesh_fallback_strict_fmul.py,test_mesh_first_types.py,test_pads_after_menu.py,test_parity_gates.py,test_pass_barrier.py,test_pass_hazard.py,test_pcache_header_read.py,test_pipeline_key_values.py,test_pipeline_state_portable.py,test_pipeline_states.py,test_present_probe.py,test_present_queue_default.py,test_present_sites.py,test_present_source_crop.py,test_program_answer_domains.py,test_program_cache_cleanup.py,test_program_cache_one_variant.py,test_push_state.py,test_queue_priority.py,test_recorder_own_idle.py,test_recorder_parts.py,test_recorder_sync.py,test_recording_admission.py,test_replay_write_order.py,test_reshade_fx.py,test_run_all_mingw.py,test_same_draw.py,test_same_dyn.py,test_sampler_admission.py,test_seed_reader.py,test_shader_store.py,test_sparse_bind_failure.py,test_sparse_bind_ranges.py,test_split_ub_flush.py,test_staging_burst.py,test_taau_typed_dispatch.py,test_table_track.py,test_target_layouts.py,test_target_reuse_memory.py,test_temporal_present_bandwidth.py,test_texel_buffer_ownership.py,test_texture_init_barrier.py,test_texture_staging_publication.py,test_ub_snapshot_default.py,test_ub_update_batch.py,test_ui_record.py,test_ui_texture_upload.py,test_vcore_video_acquire.py,test_vendor_fixes.py,test_vertex_bind.py,test_vertex_bind_range.py,test_video_catchup.py,test_video_hold_early.py,test_video_input_limit.py,test_vk_occlusion_queries.py,test_vulkan_clear_mip.py,test_vulkan_copy_span.py,test_vulkan_copy_span_gpu_compile.py,test_wb_diff_observations_gpu.py,test_widen_alpha.py,test_windows_on_linux.py,test_windows_stop.py,test_wmma16_zero_c_kchain.py,test_xinput_thread.pyMeasurements
Nothing to measure: the start's order, one access right on the builder's opens, and one more write grant.
Risks
FILE_READ_ATTRIBUTEStoo: a file's attributes, which any root's stat givesalready.
HOS_MOD_TESTS_OUTnamesone. A folder at or above the player's own is refused, as any grant is.
Checklist
Ready for review
mod-api; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named): Windows, with #2747 and #2745 merged: 669 passed, 122 failed, 47 skipped. The same 118 fail on mod-api;test_invalidate_vcore,test_mesh_args_cleanupandtest_present_semaphorespass on rerun (flaky under the full run);test_sandbox_save_dir_earlyfailed only with #2747 merged, fixed here (952b4ec3c: a stand-in for the start #2747 adds).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
The sandbox block of the Windows main and nn_fs.c's save folder choice, cut and compiled with stand-ins: the folder's check succeeds only where it can be reached (outside the container, or inside once hos_sandbox_start installed the broker's file hooks). Fails on mod-api: the confined game's early choice, before the hooks, is refused and kept, and the real check after the sandbox gets that refusal ("the folder could not be made"). Co-Authored-By: Claude Opus 5.5 <[email protected]>"the game cannot write there" said nothing of why: the confined game's case below was a refused open, which the message now names ("Windows error 5 opening a file in it"), for a player's report as for a developer. Co-Authored-By: Claude Opus 5.5 <[email protected]>host/broker_files_windows.c built with llvm-mingw's clang and run on Windows itself, serving its own process over a write root: - a GENERIC_WRITE, CREATE_ALWAYS open: BROKER_OK, the handle written to and its attributes readable; - a read-write open of that file reads it back; - a metadata open (no access, FILE_FLAG_BACKUP_SEMANTICS: Rust's std::fs::metadata): BROKER_OK, and its attributes read from the handle, as Windows' own such open allows (checked beside it); - a folder made under the root (BFILE_MKDIR): BROKER_OK; - a write-only open outside the root: still refused. Fails on mod-api with BROKER_E_FAILED, error 5: the broker's own check of each handle it opens (FileAttributeTagInfo, in opened_ok and is_dir_handle) needs FILE_READ_ATTRIBUTES, which a write-only handle and MKDIR's FILE_LIST_DIRECTORY one lack, and the check's failure is taken for a link (a folder is made, then reported refused). Wine does not check a handle's access so, which is why tests/test_broker_files_wine.py's fopen("w") and its folder pass there. Co-Authored-By: Claude Opus 5.5 <[email protected]>A confined game could not make a file it may write, nor a folder, nor read a file's time: - the broker checks each handle it opens (opened_ok's is_reparse, is_dir_handle: FileAttributeTagInfo) before it hands the game a copy, and Windows answers that only on a handle with FILE_READ_ATTRIBUTES. A write-only open (GENERIC_WRITE: fopen "w", the save folder's write test) and BFILE_MKDIR's FILE_LIST_DIRECTORY open have none, so the check failed, was taken for a link and the request refused with ERROR_ACCESS_DENIED (a folder was made first). A sandboxed start with a profile quit at its save folder's write test ("the game cannot write there (Windows error 5 opening a file in it)"); - an open of Windows' own with no access may have its attributes read, and Rust's std::fs::metadata reads a file's time from such a handle (its listing fallback is for a refused open only). The game's copy carried the request's access alone, so a confined game found no file's time: the Skip title screen found no saved game and kept the title screen, and a sandboxed test run never reached play. The broker's own opens now ask FILE_READ_ATTRIBUTES, and the game's copy carries it with the request's access: it reads nothing BFILE_STAT does not, which any root serves. sandbox.md says so. Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU, driver 621.24: dev.py game-tests of a mod with an in-game test, sandboxed with its profile. mod-api
4266ba68: the start quit at 'the save folder can't be used ... could not be made'. This branch (8639d7f0): confined, the profile's saves used, play reached, the mod's patched event flow served, 'mod tests: ok - ...', '1 passed, 0 failed, 4 skipped: ...results.json (exit 0)', results.json written. game-tests itself still prints 'the game did not start ... before ready=present' (the control bridge cannot reach a confined game: not this PR's).The one thing Risks names as not fixed here (game-tests saying "the game did not start" of a sandboxed run that passed: the control bridge could not serve a confined game) is #2742. With both merged locally, a sandboxed game-tests run reports "1 passed, 0 failed, 4 skipped (in the game)", exit 0.
ChloeNow referenced this pull request2026-11-28 17:31:53 +00:00
@review
Recommendation: Request changes. The Windows run shows the startup fix working, but two new checks hard-code GCC and can fail on supported setups that use the configured compiler. Linux results writing and a Windows launcher save-and-load run still need verification.
The change delays the confined Windows process’s save-folder selection, fixes brokered write and metadata opens, and grants test-result folders on both platforms. It addresses a demonstrated startup failure, at the cost of broader attribute access on brokered handles and an additional writable test-results grant.
Blocking (1): must change before merging.
@​fixor@​rebasetry first). (for the author)Should fix (1): not blocking, but worth doing before merging.
tests/test_sandbox_save_dir_early.py:28: This check and test_sandbox_test_results.py hard-code GCC instead of using the compiler selected by the test runner. (more on the line) Do: Use the runner’s {cc} placeholder for both RUN_ALL_ARGS declarations and honor CC for standalone runs.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
host/sandbox_linux.c:479: The new Linux results-folder grant has not been exercised in a sandboxed game run. (more on the line) Do: Run a sandboxed Linux game-tests case with an in-game test and confirm its results.json and exit status.host/broker_files_windows.c:285: The reported Windows run does not verify saving and loading a slot through a launcher profile. (more on the line) Do: On Windows, start a sandboxed launcher profile, save a slot, restart and load it.@fixcan do L1.More: does it help, other systems, switches, what was read
Does it help: Yes for the reported Windows test run: the base quit before play, while head reached play and wrote results with 1 passed, 0 failed and 4 skipped. Linux results writing and a launcher profile’s save/load cycle remain unverified.
Other systems: The Windows broker changes all brokered file opens, including saves and metadata reads; the reported run covers Windows 11 on NVIDIA. Linux receives a new writable sandbox grant but has no reported game run. The results grant applies only when HOS_MOD_TESTS_OUT is set.
Switches: HOS_MOD_TESTS_OUT already existed; this change grants its named folder to the sandbox. With it unset there is no new grant. No switch is added or removed.
Reviewed:
8639d7f012against4266ba68cc: Read the diff, commit messages, repository rules, PR template, standards, new tests, and relevant broker, sandbox-plan, save-selection and test-mode call paths. Skimmed the remaining surrounding code; did not read every changed code file in full. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run, as requested. The PR reports a Windows in-game run and game-free checks; Linux and launcher save/load runs remain outstanding.
Overlaps and merge order: The author identifies #2742 as a separate control-bridge fix; no merge dependency is established.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -280,0 +282,4 @@may have its attributes read, and Rust reads them from that handle, its fallback only for a refused open; itgives nothing BFILE_STAT does not, which any root takes) */const DWORD access_ra = access | FILE_READ_ATTRIBUTES;h = open_in(root, n1, access_ra, qp->share, nt_disp(qp->disp), nt_options(qp->flags), qp->flags & BFILE_ATTRS_OK, 0, &err, &info);L3 (should fix): The reported Windows run does not verify saving and loading a slot through a launcher profile.
When: A launcher profile uses the changed brokered save-folder and file-open paths; reaching play and writing test results does not exercise a complete save and reload.
Do: On Windows, start a sandboxed launcher profile, save a slot, restart and load it.
@ -477,2 +477,3 @@static void diagnostic_dirs(SbxInput *in) {static const char *const dirs[] = {"RX_VK_SHOTS", "HOS_PROFILE_DIR", "HOS_SHADER_DUMP", "RX_VK_DUMP", "RX_VK_HANG_DUMP"};static const char *const dirs[] = {"RX_VK_SHOTS", "HOS_PROFILE_DIR", "HOS_SHADER_DUMP", "RX_VK_DUMP", "RX_VK_HANG_DUMP","HOS_MOD_TESTS_OUT" /* (the test mode's results: dev.py game-tests' own per run) */};L2 (should fix): The new Linux results-folder grant has not been exercised in a sandboxed game run.
When: A Linux game-tests run writes outside the game and user folders and relies on this grant to produce its results; the new check inspects the source but does not demonstrate that the sandbox permits the write.
Do: Run a sandboxed Linux game-tests case with an in-game test and confirm its results.json and exit status.
@ -0,0 +25,4 @@sys.path.insert(0, str(Path(__file__).resolve().parent)) # (python -I leaves the check's own folder off the path)from srccut import between, block # noqa: E402RUN_ALL_ARGS = ["--cc", "gcc"]L1 (should fix): This check and test_sandbox_test_results.py hard-code GCC instead of using the compiler selected by the test runner.
When: On a supported Windows llvm-mingw or Linux Clang setup with CC configured but no gcc on PATH, run_all passes --cc gcc and these checks fail before testing the fixes.
Do: Use the runner’s {cc} placeholder for both RUN_ALL_ARGS declarations and honor CC for standalone runs.
Tested
mod-apiafter the squash (#2822,9e6b9c57) on Windows 11, RTX 5080: a confined start withLONGSHOT_PROFILEreaches the builder and the AppContainer, then stops atfatal: the save folder can't be used: the profile's saves folder ...\saves: the folder could not be made, your bug 1.Two notes for rebasing this onto the squashed
mod-api:host/hos_main.c: the early block's comment foruser_dir_earlychanged there (the builder's choice inside the container,LONGSHOT_SANDBOX_USER), so the commit conflicts; yourif (!hos_sandbox_in_container())guard applies as it is.host/broker_files_windows.cis gone onmod-api: the file broker is the builder's now,builder/crates/build-core/src/files_windows.rs. It looks like the same write-only-open problem:files_rules::access_mapmapsGENERIC_WRITEto0x0012_0116(noFILE_READ_ATTRIBUTES), andopen_in'sopened_okcallsis_reparse, which readsFileAttributeTagInfoon that handle and takes a failure as a link (ERROR_ACCESS_DENIED). Not run past bug 1 yet, so not confirmed.Follow-up, checked on Windows 11 (RTX 5080) against
mod-api@eaf4a48b: your bug 2 is in the Rust broker as suspected, and it also breaks content mods in a confined game.builder/crates/build-core/src/files_windows.rs's own test,files_windows::tests::the_cache_takes_files_folders_renames_and_removes, fails onmod-apion Windows (--target x86_64-pc-windows-gnullvm). First, the write-only create (op 1,GENERIC_WRITE) is refused (left: 5, right: 0). With that open givenFILE_READ_ATTRIBUTES, it fails next at the folder made by op 3 (FILE_LIST_DIRECTORY | SYNCHRONIZE): the folder is made, then refused byopen_in'sis_reparsecheck.FILE_READ_ATTRIBUTESadded in three places, all 5files_windowstests pass: op 1's open (d.access | FILE_READ_ATTRIBUTES), op 1's handle given to the game (give_access), and op 3's open (FILE_LIST_DIRECTORY | FILE_READ_ATTRIBUTES | SYNCHRONIZE).seven-rupeeexample as a profile mod. Before:content: its plan cannot be kept (...modcache\content\plans\<h>.json)andits content cannot be made: ...modcache\content\<h>\patches/rows-ActorInfo.json cannot be written, then":Rupee7" is not an item's name. After:content: 1 actor, 1 item, 1 place (its module run, made now), and its script readsits name in this game: Seven Rupee.Leaving the port to you, since it's this PR's bug.
8639d7f01240829e9d4ePorted to the squashed mod-api (
eaf4a48b9), where the builder confines the game. A sandboxeddev.py game-testson Windows with a profile hit each of these in turn on the new mod-api; with this branch it reaches play and the tests pass:hos_main.c): still chosen before the builder is reached, so "the folder could not be made". Inside the container it's now chosen after.tests/test_sandbox_save_dir_early.pyupdated to the new start: fails on mod-api with that error, passes here.files_windows.rs, the old C broker's fix moved there): a write-only open (the save folder's write test) was refused, error 5, as its handle check needs FILE_READ_ATTRIBUTES. mod-api's ownthe_cache_takes_files_folders_renames_and_removesfails on native Windows at that open and passes here.HOS_MOD_TESTS_OUT) given written, now in the builder's Windows plan (plan.rs,gather.rs), test first. Linux's plan (sandbox_linux.rs) has the same gap; not here, as I can't build it on Windows.The old C-only commits (the old broker's native test, the old plan's grant) are gone with that code. In game: Windows 11, RTX 4060 Laptop, nav-probe from a folder outside the mods folder, with #2745 and #2747: 1 passed, exit 0. The description still describes the old design; I'll rewrite it before marking ready.
WIP: fix(sandbox): Windows: a sandboxed start with a profile reaches play, its saves and the test mode's results writtento fix(sandbox): Windows: a sandboxed start with a profile reaches play, its saves and the test mode's results writtenView command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.