Repository navigation
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Blocking: the new flush test fails on Windows 11 in both cases.
Built and ran process_cmdline_test at 87dc24bc0 (MSVC RelWithDebInfo), twice, same result:
FAIL entry return: exit code 17 (want 17), buffered contents were not flushed
FAIL exit(): exit code 23 (want 23), buffered contents were not flushed
exit=1
The entry codes are right (17 and 23), so the entry and exit() path ran, but the parent reads an empty file after run_entry returns: the test's buffered FILE* was not flushed. The change adds std::fflush(nullptr) in game_exit and after the entry returns in game_thread; on this host that does not reach the stream the test opened before entering run_entry. git diff --check clean.
Duplicate: #5194 (trxoo-glitch, 09:11, earlier) is the same RT-368 work and its run_tiny_atexit ctest passes here (I verified it at c2efc27e5). The two branches conflict in runtime/shims/process.cpp. Recommend keeping #5194 and closing this one, or diagnosing why fflush(nullptr) does not flush the pre-entry stream in this test before re-submitting.
|
I reproduced both I changed only the scratch test fixture to open both handles with Allowing sharing in the fixture preserves the read-before-close check and lets it distinguish the fix from the base on this host. CPU only. AI-assisted. |
|
Reproduced @thehollowedone's result independently (Windows 11 Pro 26300, MSVC 19.44, One coordination note: #5194 fixes the same item (RT-368) in the same two places in No game files. AI-assisted (Claude Code). |
|
Tested 87dc24b on Windows 10 Pro 22H2 (19045), AMD Radeon RX 6700 XT (driver 32.0.21045.29003), MSVC 14.51.36231, Windows SDK 10.0.26100, Ninja RelWithDebInfo: fail, but the cause is in the test, not the fix.
Cause:
So the fix works, and once the test can read the file it catches the bug. Optional, not needed for RT-368:
AI-assisted comment. |
Kam471
left a comment
There was a problem hiding this comment.
Correction to my earlier blocker, based on the two independent reproductions in the comments (thehollowedone and XFlawless1):
The process_cmdline_test failures are in the test fixture, not the production change. Both probes write the expected 19 bytes, but the parent's _wfopen_s reader gets EACCES while the writer handle is still open; opening both with _wfsopen(..., _SH_DENYNO) makes the test pass on this PR and fail on main 3faac557, which is the differential the test wants.
So: product code is fine; the fixture needs the shared-open change before the test can be trusted. Still the same RT-368 work as #5194 (the branches conflict in runtime/shims/process.cpp), so one of the two should land — this PR additionally covers the returning-entry flush and the process_cmdline probe.
|
Tested 87dc24b on Intel UHD 770, driver 32.0.101.7088, Windows 11, MSVC 19.44, with a fresh native build (gta6rt.exe and process_cmdline_test.exe deleted and rebuilt): process_cmdline fails. ctest prints "Test #37: process_cmdline ... ***Failed 0.68 sec" and "0% tests passed, 1 tests failed out of 1", and running process_cmdline_test.exe directly exits 1 with "FAIL entry return: exit code 17 (want 17), buffered contents were not flushed" and "FAIL exit(): exit code 23 (want 23), buffered contents were not flushed". On main 3faac55, built fresh the same way, the same ctest entry passes ("Test #37: process_cmdline ... Passed 1.67 sec") and the direct run exits 0. The two new probes exist only in this PR's test, so the main pass shows the rest of the test passes there, not that the probes pass. I did not look into the cause. An RTX 4080 run of the same head fails the same two probes. AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
Root cause confirmed on Windows 11 (MSVC 19.44, RelWithDebInfo): the production flush works; the test cannot read its own file.
dumpbin /disasmshowscall [__imp_fflush]ingame_exit,game_cexitandgame_thread, and the EXE importsfflushfrom the hostucrtbase.- With a temporary probe reading the writer's own handle (
_get_osfhandle+GetFileSizeEx) immediately afterrun_entry:19bytes with the flush,0withstd::fflush(nullptr)removed (whileftellstill showed 19 buffered). So the data is written and the flush is what writes it. - The failure is a Windows sharing violation:
_wfopen_sopens with_SH_SECURE(UCRTfopen.cpp:80), whose share mode isFILE_SHARE_READfor a reader; the writer still holdsGENERIC_WRITE, so the read returns 13/EACCES andcontentsstays empty. Even aCreateFileWwith READ|WRITE|DELETE sharing fails against the writer's share mode. - Opening both sides with
_wfsopen(..., _SH_DENYNO)and asserting the read open succeeded makes the test pass (contents="buffered C stream\n", exit 0) with this PR's production code, while the same adjusted fixture fails on3faac557. That is the differential the test wants.
So no production change is needed for this failure; the fixture needs the shared-open fix (and should fail loudly if the read open fails, so a sharing problem cannot look like a flush problem again). The PR still overlaps #5194's RT-368 change; either can land once this test is fixed.
|
Rechecked The updated fixture checks the still-open writer handle with CPU only, synthetic files. AI-assisted. |
|
Tested f71b71d on RTX 3060, driver 617.14, Windows 11, MSVC 14.44 RelWithDebInfo: pass
AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
Retested at head f71b71d (was 87dc24b), base main 3faac55, Windows 11 / PowerShell, worktree under %TEMP%\opencode.
Fixture sharing fix: present, but not as _wfsopen(_SH_DENYNO). The writer is still _wfopen_s(..., L"wb"), which is non-sharable; I confirmed a concurrent read open returns errno 13 (EACCES). The fixture now closes the writer before the reader opens, and preserves the anti-cleanup property by checking GetFileSizeEx(_get_osfhandle(_fileno(stream))) on the still-open stream before fclose. The read open itself is not separately asserted, but a failed open leaves contents empty and fails contents_match, so it cannot false-pass. Equivalent fix.
Head results (vcvars64 + Ninja):
ninja process_cmdline_testLEONIDA_VK_DEVICE='RTX 5070 Ti' process_cmdline_test.exe— exit 0, 0 FAIL lines (the binary prints one summary line and no per-check PASS lines, so pass = exit 0). Both new probes (entry-return 17,exit()23) ran and passed.ctest -R '^run_tiny_atexit$' --output-on-failure— 1/1 Passed (0.85 s).- Configure used:
-G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON -DLEONIDA_BUILD_WINDOWS_RUNTIME=ON -DVulkan_INCLUDE_DIR=C:/VulkanSDK/1.4.363.0/Include -DVulkan_LIBRARY=C:/VulkanSDK/1.4.363.0/Lib/vulkan-1.lib
Negative control (main 3faac55, only this test file copied in): exit 1, both probes fail:
FAIL entry return: exit code 17 (want 17), stream size 0 (want 18), contents match
FAIL exit(): exit code 23 (want 23), stream size 0 (want 18), contents match
(contents match only because fclose in test cleanup flushed afterwards — the pre-close size check is what catches it.)
git diff --check: clean, working tree and 3faac557b..HEAD.
Verdict: PASS — differential confirmed (head passes both probes, main fails both), RT-368 ctest passes, no whitespace issues. Minor non-blocking nit: the reader-open failure is only reported as "contents differ".
|
Verification update at
Overlap with #5194 is now explicit in |
|
Tested Negative control. On So both halves of the check — the buffered stream reaching disk, and the exit code surviving — fail before the change and pass after it, on this machine. The test writes only to a temp file it creates and deletes. I did not test the stated dependency (#5194); this is only the pre-cleanup regression on its own base. AI-assisted. No game data. |
|
process_cmdline_test is flaky at f71b71d on Intel UHD 770, driver 32.0.101.7088, Windows 11. Running the test binary from a clean tree: of 200 runs, 196 exited 0 with the test's result line, and 4 ended before the test finished with no output at all, 3 with exit code 23 and 1 with exit code 17. A further 100 runs exited 0 every time, so it is intermittent, but ctest is affected too: a loop of ctest over this test reported ***Failed for test 37 process_cmdline on iteration 3, with no output from the test. With the main test file and this head's production code, 100 runs exited 0 every time, and on main 3faac55 100 runs also exited 0 every time. Expected: every run reaches the test's result line and exits 0. AI-assisted. |
|
Tested
AI-assisted (Claude Code). |
Claimed in the coordination issue as: RT-368 in #5156.
Depends on: #5194 (overlapping RT-368 production change; this PR's pre-cleanup regression is complementary).
What and why
A normal CRT exit flushes every open C stream. The mapped-title shim ran the title's
atexithandlers but then ended the run without flushing them; the host only flushesstdout/stderrafterwards, so buffered output on an independent file stream could be lost.exit()._exit,quick_exit,ExitProcessandabortunchanged.process_cmdline_testwith entry-return andexit()probes that write a temporary file without flushing or closing it. The test checks the open stream's file size before closing it, so later host cleanup cannot hide the bug.Tested
git diff --check— passed.f71b71: Windows build succeeded andprocess_cmdlinepassed. The only remaining Windows failure wasd3d12_sparse_queue_family(vkCreateInstancefailed); the Linux job failed in untouchedvk_harness.cpppipeline-binary declarations.mainRuntime CI reproduces the same Linux pipeline-binary build failure and Windowsd3d12_sparse_queue_family/vkCreateInstancefailure, confirming both predate this PR.mainafter allowing file sharing in the original fixture (see PR comments).AI-assisted: yes, Kimi Code.
Checklist