Menu: the activation-context manifest is written to a fixed name in %TEMP%, follows links, and is never removed #2272
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2272
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@itsonewi on GitHub · 2026-11-25 11:57 UTC · original
Summary
crates/xcl/src/main.rs(1a0bbe3),Ui::enter():The manifest is the Common-Controls 6 dependency that makes the task dialog look right; the file is a means to an end. Four things about how it is made:
%TEMP%is%LOCALAPPDATA%\Tempfor a normal user, but it isC:\Windows\Tempfor a service, it can be redirected or roamed by policy, and a shared or lab machine can have it writable by more than one account.std::fs::writeiscreate(true).truncate(true)and follows reparse points. Ifxcl-menu.manifestalready exists as a symlink, junction or hard link, the write lands on its target and truncates it first. Twoxcl.exewindows opening the menu at once also write the same file.CreateActCtxW, in the process that is about to run the game. An activation context can list<file name="...">entries and dependency assemblies, which is a way to name binaries to load.%TEMP%after the menu closes, and if the write fails (std::fs::write(...).ok()swallows the error) an older file left by an earlier run, or by someone else, is what gets activated - with no message.Suggested fix
There is already a precedent in the tree:
crates/xcl/src/rpf.rscreates its temporary file withcreate_new(true), in a loop, and owns its removal throughTempPath:Doing the same here fixes 2 and 4 together:
create_newrefuses at once when the name exists or is a link, so the XML is never written into someone else's file, and a guard struct that deletes the path onDrop(orFILE_FLAG_DELETE_ON_CLOSEthroughOpenOptionsExt::custom_flags) leaves nothing behind. A unique name (pid + counter, asrpf.rsdoes withTEMP_ID) also removes the two-windows race.If the file is dropped for good instead,
CreateActCtxWalso takeslpResourceNamefromGetModuleHandle(NULL)- but the comment inUi::enter()says a manifest insidexcl.exewould apply to the game as well, so that is not an option here; the fix is the file, not the location.Not tested
1a0bbe3without a checkout. The menu is only reached by double-clickingxcl.exewith no arguments (started_by_double_click()), so this is a hardening report, not a reproduced failure.AI use
crates/xcl/src/main.rsandcrates/xcl/src/rpf.rson1a0bbe3and wrote this report; the human account checked both files before opening it.@Decodere on GitHub · 2026-11-25 12:09 UTC · original
Taking #2272 in
crates/xcl/src/main.rs(Ui::enter/Ui::drop).Plan:
%TEMP%\xcl-menu.manifeststd::fs::writewith an RAIITempManifestcreated viaOpenOptions::new().write(true).create_new(true)using a uniquexcl-menu-<pid>-<seq>.manifestname (retrying onAlreadyExists, followingrpf.rs'sTempPathpattern), cleaning up on write error and removing the file onDropas soon asCreateActCtxWcompletes.ACTCTXhandle (ReleaseActCtx(h)) ifActivateActCtxfails, and guardCoUninitialize()onCoInitializeEx(...) >= 0.CreateActCtxW/ActivateActCtxactivation and teardown) plus workspace build/tests andpr_check.py.AI use: drafted with Google Antigravity (Gemini 4 Neon); implementation and Windows tests will run locally.
@itsonewi on GitHub · 2026-11-25 15:55 UTC · original
The plan matches the issue, and the extras are welcome:
ReleaseActCtxon a failedActivateActCtxand theCoUninitializeguard are two leaks the report did not name, so please keep them in.Two things from the source that may save a round trip:
CreateActCtxWreturns is safe: the activation context is parsed from the file inside that call, so the file is not needed afterwards. That is what makes the RAII-with-Drop shape correct here rather than a keep-it-until-exit workaround.pid+ sequence is enough, but keep theAlreadyExistsretry bounded and return the error after a few tries instead of looping, since%TEMP%can be a redirected folder with odd ACLs.Cheapest check that the manifest is really parsed: an empty or truncated manifest makes
CreateActCtxWfail withERROR_SXS_CANT_GEN_ACTCTX, so a passingCreateActCtxWon the written bytes is already the assertion.Measured on the source only (no build here).
AI use: read
main.rsandrpf.rsonmainthrough the GitHub API to check the plan against the existingTempPathprecedent; no code was written by an agent here and no build was run.