sharpemu/tests/SharpEmu.Libs.Tests
Slick Daddy bb3318a503
kernel: return -1/errno from POSIX file syscalls on failure (#461)
* kernel: return -1/errno from POSIX open and fstat on failure

The POSIX-named open (wuCroIGjt2g) and fstat (mqQMh1zPPT8) exports routed
straight to the raw sceKernel* implementations, which report failure via
the 0x8002xxxx OrbisGen2Result sentinel in the return value. libc callers
follow the POSIX ABI and expect -1 with errno set, so they stored the
sentinel as a valid fd. Unity's IL2CPP file layer did exactly this while
probing the absent /app0/Media/il2cpp.usym: open returned NOT_FOUND
(0x80020002), the guest kept the sentinel as an fd, passed it back into
fstat, and eventually dereferenced a null pointer (vmovups xmm0,[rdi],
rdi=0) deep in a native .prx, crashing with 0xC0000005.

Wrap both entry points to translate a failed raw result into -1/errno,
mirroring the existing PosixStat/PosixLseek convention. Add a shared
PosixFailure helper (fstat maps a bad handle to EBADF; path calls default
to ENOENT) and route it through PosixStat too. Covered by two regression
tests reproducing the missing-file and misused-sentinel-fd cases.

* kernel: return -1/errno from POSIX close, read and write on failure

Same defect class as open/fstat: the POSIX-named close (bY-PO6JhzhQ),
read (AqBioC2vF3I) and write (FN4gaPmuFV8) exports forwarded the raw
sceKernel* core result, leaking the 0x8002xxxx sentinel to libc callers
that expect -1/errno on a bad fd. close in particular is on the crashing
Unity path, invoked on the sentinel the guest mistook for an fd.

Wrap all three through PosixFailure with EBADF as the fd-not-found errno.
Add regression tests for each, and correct the socket test that had
locked in the old raw-sentinel contract for a double close.

---------

Co-authored-by: slick-daddy <slick-daddy@users.noreply.github.com>
2026-07-20 14:17:08 +03:00
..
Agc Gpu runtime stalls (#410) 2026-07-19 00:31:50 +03:00
Ampr [Tests/HLE] Cover APR resolve, stat, and streaming flow (#272) 2026-07-16 19:57:45 +03:00
Audio [AJM] Track registered codec instance lifecycle (#352) 2026-07-18 03:02:19 +03:00
AvPlayer [AvPlayer] Resolve guest media within app0 (#347) 2026-07-18 02:42:30 +03:00
Cpu cpu: emulate AMD-only Zen 2 instructions in software (#449) 2026-07-19 21:57:42 +03:00
Fiber test: add Fiber exports contract tests (13 tests) (#428) 2026-07-19 13:53:33 +03:00
Font [HLE] Stub ContentExport, Font, and Pad calls Astro Bot needs to boot (#298) 2026-07-17 04:34:48 +03:00
GUI PerGameSettings Null toggles (#453) 2026-07-20 01:30:13 +03:00
HLE Prevent invalid SaveData writes from damaging guest memory (#444) 2026-07-19 20:27:17 +03:00
Json [SourceGenerators] Compile-time SysAbi export registry, analyzers, and build-generated aerolib.bin (#204) 2026-07-16 00:00:32 +03:00
Kernel kernel: return -1/errno from POSIX file syscalls on failure (#461) 2026-07-20 14:17:08 +03:00
LibcInternal Add libc heap trace contract tests (#409) 2026-07-19 03:25:42 +03:00
Loader test: add Kernel/Loader unit tests (22 tests) (#373) 2026-07-18 20:19:55 +03:00
Logging Reject undefined numeric LogLevel values (#390) 2026-07-18 15:47:19 +03:00
Memory memory: back the free pages of a partially-overlapping fixed mapping (#458) 2026-07-20 09:08:29 +03:00
Network Fix sceNetHtonl/Htons/Ntohl/Ntohs discarding their converted result (#211) 2026-07-16 16:24:34 +03:00
Pad [HLE] Stub ContentExport, Font, and Pad calls Astro Bot needs to boot (#298) 2026-07-17 04:34:48 +03:00
PlayGo [PlayGo] Reject authoritative unknown chunk loci (#242) 2026-07-16 19:22:33 +03:00
Pthread Fixes a Mutex Issue Preventing Some UE Titles From Booting (#451) 2026-07-19 13:20:05 -06:00
Random [HLE] Add RandomExports HLE (#413) 2026-07-18 23:44:57 +03:00
Rtc Fix sceRtcConvertLocalTimeToUtc failing on non-UTC hosts (#210) 2026-07-16 00:04:35 +03:00
SaveData Prevent invalid SaveData writes from damaging guest memory (#444) 2026-07-19 20:27:17 +03:00
ShaderCompiler [ShaderCompiler] Fix VReadlane scalar destination field (#344) 2026-07-18 02:41:07 +03:00
SystemService [SystemService] Write notice skip flag as byte (#346) 2026-07-18 02:41:38 +03:00
Tls [AGC/Vulkan] Extend PS5 runtime and rendering compatibility (#216) 2026-07-16 02:02:34 +03:00
VideoOut Encode linear-float flips to sRGB at present (#448) 2026-07-20 01:29:38 +03:00
AerolibCatalogTests.cs [SourceGenerators] Compile-time SysAbi export registry, analyzers, and build-generated aerolib.bin (#204) 2026-07-16 00:00:32 +03:00
FakeCpuMemory.cs [Json] Implement sce::Json::Value and String (construct / set / destroy) (#169) 2026-07-15 01:49:33 +03:00
SaveDataStorageTests.cs [Gpu] Metal backend: complete IGuestGpuBackend implementation on AppKit + Metal (#283) 2026-07-18 20:32:00 +03:00
SharpEmu.Libs.Tests.csproj Gui Settings Null list Entries (#430) 2026-07-19 13:53:56 +03:00
Sse4aExtrqBlendPatchTests.cs [Gpu] Metal backend: complete IGuestGpuBackend implementation on AppKit + Metal (#283) 2026-07-18 20:32:00 +03:00
SysAbiRegistryTests.cs [SourceGenerators] Compile-time SysAbi export registry, analyzers, and build-generated aerolib.bin (#204) 2026-07-16 00:00:32 +03:00