Repository navigation
fix(libkernel): serialize positioned file transfers on Windows - #4973
Conversation
|
Taking this one over #3861. Three things before it can go in:
A lock per descriptor instead of one for all files would be better, as asked on #3861. |
e2e4ba2 to
e69306f
Compare
|
Done, pushed as 31bcf98..e69306f (branch rebased, no merge commit): 1) original commit cherry-picked with its author kept; 2) the same per-descriptor lock now covers NativeLseek, so a seek between the positioned save and restore can no longer clobber either side; 3) new guest_positioned_race test (pread vs read+lseek on one descriptor, both sides verified) fails on main first run, passes 10/10 with the fix; 4) one mutex per descriptor number, shared across dup, entries persist so close/reuse cannot strand a waiter. The debt entry for the Windows positioned race now describes the serialized behavior. |
e69306f to
f9881ad
Compare
|
Linux build (Arch, GCC 16.2.1, Release,
|
|
Windows counter-test (follow-up): Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, this PR merged onto Not tested: Linux, a console, a title run. AI-assisted (Claude Code). |
|
Data point from a third Unity title, for scope: Cult of the Lamb (PPSA06465) also faults intermittently on |
The per-descriptor lock exists only in the Windows transfer path, so ShareDescriptor calls SharePositionedTransfer under _WIN32 like GuestFileLockShare. Linux failed to link libkernel with an undefined reference to it.
f9881ad to
296ff64
Compare
|
Rebased onto main (bf8dc61) and force-pushed. The only conflict was the include list in |
What
Rebases #3861 (open but conflicting since Oct 12) onto current
main. Serializes Windows file-position transfers with a mutex per descriptor, shared across duplicated descriptors: positioned transfers (NativePositioned_nid_no_patch), plain transfers (NativeTransfer,NativeRead,NativeWrite) and seeks (NativeLseek) of one descriptor can no longer interleaveSetFilePointerExpositioning. Entries persist per descriptor number; a lock is only ever held alone, so no new lock order.Supersedes #3861; that PR can be closed if this one is accepted.
Tested
guest_positioned_race(concurrentpreadagainstread+lseekon one descriptor, verifying both sides) fails onmainon the first run and passes 10/10 with the fix;file_position,guest_posix_filesystem,guest_filesystem,guest_file_vector,file_streams,guest_aioall pass (7/7). Linux/macOS rely on CI.Checklist
main; no other open PR implements the same functions (rebases conflicting fix(libkernel): serialize positioned file transfers on Windows #3861; supersedes it)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)