Commit Graph
245 Commits
Author SHA1 Message Date
Dean 8972f8ae3c Merge pull request #8129 from Th3EvilGod/codex/libc-precise-thread-sleep
fix(libc): use precise Windows thread sleep
2026-10-20 18:31:11 +13:00
Dean 329b9aa1a7 Merge pull request #7988 from MarrasFederico/feat/libc-getifaddrs-link-entries
feat(libc): list each interface's AF_LINK entry in getifaddrs on Linux
2026-10-20 17:51:27 +13:00
Dean bae00fad0a Merge pull request #7998 from priyanshrv-netizen/feat/libc-bessel
feat(libc): implement j0, j1, jn, y0, y1 and yn
2026-10-20 17:50:11 +13:00
Dean Galvin 20f75e94e0 Merge main into pr-8037
# Conflicts:
#	core/libs/tests/GuestStrings.cpp
2026-10-20 17:40:21 +13:00
Dean 1ae92bb7c9 Merge pull request #8174 from xXPBSXx/fix/rename-dot-component-fb
fix(libc): fail a rename of a path that ends in a dot component with EINVAL
2026-10-20 16:23:33 +13:00
priyanshrv-netizenandClaude Opus 5.5 16a7cece3b feat(libc): implement j0, j1, jn, y0, y1 and yn
The double Bessel functions follow the system libc.prx: FreeBSD msun
e_j0.c, e_j1.c and e_jn.c with every multiply-add the console fuses
done as one FMA, and the console's constant results for zero and
negative arguments of the second kind.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-20 06:38:32 +05:30
xXPBSXxandClaude Sonnet 5.5 49940998cd docs(libc): list the lookup order and the backslash separator among the rename dot component differences
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 02:57:14 +02:00
xXPBSXxandClaude Sonnet 5.5 9899ba0fa2 fix(libc): fail a rename of a path that ends in a dot component with EINVAL
rename and sceKernelRename resolved "dir/." to "dir" and renamed the directory. FreeBSD 11.4's lookup fails a last component of "." for DELETE and RENAME with EINVAL, for the source and the destination alike. Check the guest string before it is resolved: a last component of "." (also under trailing slashes) fails with EINVAL when its parent exists, ENOENT when it does not and ENOTDIR when it is not a directory.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 02:57:14 +02:00
xXPBSXxandClaude Sonnet 5.5 1ab777e257 docs(libc): list the backslash separator and the sceNgs2ParseWaveformFile exception among the path name length differences
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 02:47:58 +02:00
xXPBSXxandClaude Sonnet 5.5 6bc6c444e0 fix(libc): fail an oversized guest path name with ENAMETOOLONG
stat, open, mkdir, rename and the other calls that resolve a guest path answered ENOENT (or EIO for rename) for a name longer than 255 bytes or a path of 1024 bytes or more, because the host path just did not exist. FreeBSD 11.4's namei fails a component above NAME_MAX and a path of MAXPATHLEN bytes with ENAMETOOLONG. Check both limits on the guest string before it is resolved; FilesystemError already maps the error to 63.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 02:46:53 +02:00
hamb3r 47591f2e92 docs(debt): update sceLibcBacktrace technical debt entry for Windows 2026-10-20 03:28:37 +03:00
hamb3r 387be86004 docs(debt): move Dinkumware thread debt entries from libSceAmpr to libc 2026-10-20 03:22:13 +03:00
Adrià fafadca12c Merge pull request #7529 from Aspct3434/feat/swscanf-pointer
feat(libc): scan %p in swscanf and swscanf_s
2026-10-20 02:09:37 +02:00
Th3EvilGod 81b28cef61 fix(libc): use precise Windows thread sleep 2026-10-20 03:21:28 +04:00
Adrià 8b20da70a1 Merge pull request #7546 from ionut27001/fix/libc-rand48-zero-extend
fix(libc): return jrand48 and mrand48 zero-extended as measured on a PS5
2026-10-20 00:51:07 +02:00
Ishmam Ahmed 0bad015e21 fix(libc): keep the Linux call trace report when two threads abort
A thread that lost the race to write the report passed SIGABRT on straight away, and the default action ended the process while the first thread was still writing. It now waits for the report to finish, polling with nanosleep for at most 2 seconds, before it chains. guest_call_trace_abort_race aborts from two threads at once and checks the whole report; it failed 35 times in 50 without the wait. Reported by jotitadev.
2026-10-19 22:56:02 +01:00
Ishmam Ahmed 0454726744 fix(libc): write the Linux call trace report with signal-safe calls only
The SIGABRT handler used stdio and dladdr, so an abort raised while another thread held the stderr lock or the loader lock hung instead of ending. The report is now formatted into a stack buffer and written with write(2). Callers are named from a module list taken with dl_iterate_phdr when imports are traced, and import counts are read without a lock from a fixed record array. The abort test now holds the stderr lock in another thread, which timed out before this change.
2026-10-19 22:55:08 +01:00
Ishmam Ahmed d128ce7bb8 feat(libc): record traced system library calls on Linux
Build the call tracer for Linux as well as Windows. The thunk area is a
memfd mapped twice, writable and executable, and threads are named by
gettid. Linux has no crash report, so the first traced import installs a
SIGABRT handler that prints the last calls and the most called imports,
then passes the signal on to the previous handler.

guest_call_trace and guest_call_trace_abort now run on Linux too.
2026-10-19 22:55:07 +01:00
Alexej Szpevák 675ff30898 feat(libc): scan 16-bit wide conversions in the sscanf family on Linux
sscanf, vsscanf, sscanf_s and vsscanf_s threw on Linux for %ls, %lc, %l[, %S and %C, because glibc stores a 32-bit wchar_t per character into the guest's 16-bit buffer. ScanGuest, the per-directive scanner the _s forms already use, now scans those fields itself: the input is decoded as UTF-8, mirroring the narrow printf family's UTF-8 output, and each character is stored as one 16-bit unit, the width and the _s size counting characters; %ls skips leading white space and stops at the next, %l[ matches an ASCII scanset with ranges and negation, and a %lc field that meets the end of the input early keeps what it read, as FreeBSD's convert_wchar does. sscanf and vsscanf route a format with a wide conversion through ScanGuest and keep the host path otherwise. The UTF-8 decoding and scanset matching live in ScanWideField.cpp, which throws for input that is not UTF-8, a character outside the BMP, a scanset member outside ASCII and positional arguments next to a wide conversion; wide conversions in fscanf still throw.
2026-10-19 22:30:07 +02:00
Dean 1e774a3b22 Merge pull request #7872 from ErenYeager1836/feat/libc-throw-bad-optional-access
feat(libc): implement std::_Throw_bad_optional_access
2026-10-20 07:21:55 +13:00
Federico Marras 89b1b53176 feat(libc): implement bounded decimal parsing with strtonum 2026-10-19 20:19:08 +02:00
Ondra97 ce81a77d1a fix(libc): avoid premature scaled hyperbolic overflow 2026-10-19 19:47:19 +02:00
Adrià 48790e0233 Merge pull request #7039 from nabil88/fix/windows-libkernel-and-tests
feat(libkernel): implement getdtablesize and fix Windows host-tree removal
2026-10-19 19:36:18 +02:00
Adrià 68447804da Merge pull request #6975 from T3cm0/bionic/libc-addstd
feat(libc): implement ios_base::_Addstd
2026-10-19 19:35:57 +02:00
Federico Marras 792fb27631 feat(libc): list each interface's AF_LINK entry in getifaddrs on Linux
getifaddrs listed only the host's IPv4 and IPv6 addresses, so the
per-interface AF_LINK entries FreeBSD's getifaddrs puts first were
missing, and with them the interface index, hardware address, MTU and
counters and every interface without an address.

On Linux each interface now starts with an AF_LINK entry, followed by
its addresses, as FreeBSD 11.4's getifaddrs orders them. Its address is
a sockaddr_dl with the host index, type, name and hardware address
(none for a loopback), sized as FreeBSD's if_attach sizes it. Its
ifa_data is a 152-byte FreeBSD if_data filled as if_data_copy fills it:
type, address and header length, link state, MTU, speed and the host's
packet, byte, error, drop and multicast counters from sysfs, or the
host list's 32-bit counters when sysfs cannot be read. Fields with no
host equivalent are 0 and listed in the debt entry. Windows is
unchanged.
2026-10-19 18:57:12 +02:00
Dean 738d884102 Merge pull request #7878 from xxLnolan/fix/libc-paf-mspace-memalign
fix(libc): implement PAF mspace memalign
2026-10-20 05:54:04 +13:00
Dean a39411c67a Merge pull request #7906 from Rajkamalcode/fix/libc-bessel-zero
fix(libc): return -inf from y0f, y1f and ynf at zero
2026-10-20 05:52:35 +13:00
Adrià 0fbfd91e5e Merge pull request #6985 from Lorkydey/feat/libc-floating-point-controls
feat(libc): implement floating-point rounding and exception flags
2026-10-19 17:54:33 +02:00
Nithishvelan M e775e456d8 fix(libc): add bad_optional_access exports, test, and clarify debt 2026-10-19 21:20:02 +05:30
Adrià c4708fa207 Merge pull request #6916 from MarcZX10/codex/carry-tz-6910
fix(libc): honor guest TZ in time conversions
2026-10-19 16:08:10 +02:00
Rajkamalcode cea6fabfae fix(libc): return -inf from y0f, y1f and ynf at zero
The guest's second-kind Bessel functions return -inf and raise the divide-by-zero exception for x = +-0 (see e_jn.c), but the UCRT returns NaN for y1 and yn. Route x == +-0 through a shared helper, cover ynf(2, 0) in the guest math test, and note the special case in the libc technical debt.
2026-10-19 18:31:00 +05:30
UAQ Taxi a968336825 fix(libc): remove Windows trees without the remove_all symlink hang
MinGW libstdc++ up to GCC 16 does not treat a reparse point as a link in
std::filesystem::remove_all, so a host tree that holds a symlink is walked
through the link and never returns. Add RemoveTree, which removes the tree
itself on Windows, and use it where save data, app content and the shader
disk cache removed host trees. The libstdc++ fix is in GCC 17 (88856ad855ae).
2026-10-19 14:49:49 +02:00
T3cm0 6fdb88fd48 fix(libc): share slot 8 in ios_base::_Addstd as the console does 2026-10-19 14:41:10 +02:00
tecmo 4bf4fc9864 feat(libc): implement ios_base::_Addstd
Queue the stream in the table of the 8 standard stream
slots of Dinkumware's ios.cpp: the first free slot or the one
that already holds the stream, with a reference count per slot,
and the destructor suppresses the destruction of a standard
stream while its slot still has open references.
2026-10-19 14:41:10 +02:00
babyhuey 4a5ce8a094 fix(libc): adopt the guest SDK allocator only when the title replaces the heap
A bundled libc.prx can export the ten allocator NIDs while forwarding
them to HLE, so adopting its exports for a title whose replacement
table is empty sends HLE allocations back into themselves. Keep the
default heap in that case, as before the guest SDK adoption.
2026-10-19 08:39:37 -04:00
Adrià 980da5090d Merge pull request #6842 from milescoviello/fix/scripting-heap-own-blocks
fix(libc): give the scripting heap hooks blocks from libc's own heap
2026-10-19 14:03:41 +02:00
xxLnolan 30454880de fix(libc): implement PAF mspace memalign 2026-10-19 13:59:05 +02:00
Nithishvelan M 2165427879 feat(libc): implement std::_Throw_bad_optional_access
PPSA26578 (issue #7624) imports _ZSt26_Throw_bad_optional_accessv (NID
KwzEip7m6TM) from libc, and its bundled libc.prx does not export it,
causing the process to exit with 0xC0000139 (GetLastError: 127).

Implement std::bad_optional_access type record and vtable deriving from
std::exception, thrown through ThrowPlain, with what() returning
"bad_optional_access", and add unit test coverage in ExceptionRuntime.
2026-10-19 17:22:27 +05:30
Dean 6762694735 Merge pull request #7761 from angleboyndn-stack/fix/libc-secure-string-destination-limits
fix(libc): reject oversized secure string destinations
2026-10-20 00:52:00 +13:00
MarcZX100 94f035da1f docs(libc): correct timezone interaction note 2026-10-19 13:03:54 +02:00
MarcZX100 89fb0ddb7a docs(libc): note host timezone interaction 2026-10-19 13:03:54 +02:00
MarcZX100 03fbf57208 docs(libc): move timezone debt to its component file 2026-10-19 13:03:54 +02:00
Dean f72c7aacfa Merge pull request #7506 from cadenasynyster/fix/libc-throw-bad-variant-access
feat(libc): implement std::__throw_bad_variant_access
2026-10-19 23:54:48 +13:00
Adrià 3050105f24 Merge pull request #6707 from karimibrahim07/feat/libc-qsort-s
feat(libc): implement qsort_s
2026-10-19 11:47:03 +02:00
Adrià 959cfdd1c5 Merge pull request #6686 from DavidSamir/fix/libc-mktime-before-1900-macos
fix(libc): convert mktime before 1900 from the zone's own offsets on macOS
2026-10-19 10:59:57 +02:00
Adrià 096279ed25 Merge pull request #6610 from JJenkx/fix/linux-sdk-heap-owner
fix(libc): share the guest SDK application allocator
2026-10-19 09:38:02 +02:00
Emanuele b687368fac docs(libc): order the macOS unmappable range by macOS version
The range starts at 0x10_0000_0000 on macOS 26.5 and at 0xF_C000_0000 on
macOS 27. The M2 Max on macOS 27.2 shows the same start as the M4 Pro on
27.0.1, so the line lists the macOS version first and the chips only as
the machines it was measured on.
2026-10-19 08:55:20 +02:00
ShinMalphur fed4344c72 docs(libc): record secure string size assumptions 2026-10-19 13:11:36 +06:30
Adrià dc54701e49 Merge pull request #6541 from wachi35676/fix/libc-fopen-random-device
fix(libc): read /dev/random and /dev/urandom through fopen
2026-10-19 08:38:06 +02:00
ionut27001andClaude Opus 5.5 ae662c873d fix(libc): parse NaN payloads in strtod as measured on a PS5
In a payload process on a PS5 (firmware 12.70), the strtod and wcstod
of libSceLibcInternal.sprx keep the payload of a NAN(...) sequence,
read as FreeBSD 11's gdtoa hexnan reads it, under the quiet bit and
with the sign. strtof, wcstof, strtold and wcstold return the positive
default quiet NaN whatever the sign and the sequence, and consume a
sequence of letters, digits and underscores up to its closing
parenthesis. Here every NaN lost its payload, and strtof and strtold
kept the sign.

The model reproduces the 64 NaN inputs that p11, p14, p27 and p33
measured, including blanks and other characters inside the parentheses
and unterminated sequences, and the test now pins them. It also pins
two p71 cases measured through strtod: nan(1 2), and "nan( " followed
by NUL and ")". In hexnan, a blank after a payload digit, while a
32-bit word of the payload is still free, starts a blank skip that has
no NUL check, so when only blanks follow up to the terminating NUL the
console reads past it (p71); that case throws here. A blank right after
"nan(" is skipped with a NUL check, and the console stopped at the NUL
there.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 09:20:41 +03:00