libc: verify regular-file fpurge after wide-character pushback #28693

Open
opened 2026-12-02 22:55:21 +00:00 by JJenkx · 0 comments
JJenkx commented 2026-12-02 22:55:21 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-12-02T22:55:21Z.


What happens

On the Linux libc provider, a regular-file fpurge returns 0 after ungetwc(U+00E9), and the following wide read yields original file data. The same sequence without purge returns the pushed character.

Title, test or build step

Standalone host fixture using the AnyPS5 libc exports with the guest calling convention. It opens a relative scratch file containing abcdef in binary read mode.

AnyPS5 commit

Linux Release main b396d834cb05 and PR #27537 head 2f17db0b0606. The fixture verifies the loaded libc provider before each run.

System

Arch Linux x86-64, kernel 7.3.6-arch1-2. CPU-only fixture.

Steps to reproduce

  1. Open the scratch file through AnyPS5 fopen. Read a, b, c and d with fgetwc.
  2. Call ungetwc(0x00e9) and check that it returns 0x00e9.
  3. For one run, immediately read twice with fgetwc. For a fresh run with the same setup, call fpurge first and check that it returns 0, then read twice.

Log

Provider Wide read without purge Wide read after purge
Main b396d834cb05 U+00E9, e c, d
PR 2f17db0b0606 U+00E9, e c, d

What was checked

The narrow control reads through d, pushes Q with ungetc, calls ferror, then purges. It returns d, e on main and Q, e on the PR head. The wide result is already present on main. The published console fixture covers one byte of pushback, so the expected wide-character behavior still needs console qualification. Review finding

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6756278191 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/28693). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-12-02T22:55:21Z. --- ### What happens On the Linux libc provider, a regular-file `fpurge` returns 0 after `ungetwc(U+00E9)`, and the following wide read yields original file data. The same sequence without purge returns the pushed character. ### Title, test or build step Standalone host fixture using the AnyPS5 libc exports with the guest calling convention. It opens a relative scratch file containing `abcdef` in binary read mode. ### AnyPS5 commit Linux Release main `b396d834cb05` and PR #27537 head `2f17db0b0606`. The fixture verifies the loaded libc provider before each run. ### System Arch Linux x86-64, kernel 7.3.6-arch1-2. CPU-only fixture. ### Steps to reproduce 1. Open the scratch file through AnyPS5 `fopen`. Read `a`, `b`, `c` and `d` with `fgetwc`. 2. Call `ungetwc(0x00e9)` and check that it returns `0x00e9`. 3. For one run, immediately read twice with `fgetwc`. For a fresh run with the same setup, call `fpurge` first and check that it returns 0, then read twice. ### Log | Provider | Wide read without purge | Wide read after purge | | --- | --- | --- | | Main `b396d834cb05` | U+00E9, `e` | `c`, `d` | | PR `2f17db0b0606` | U+00E9, `e` | `c`, `d` | ### What was checked The narrow control reads through `d`, pushes `Q` with `ungetc`, calls `ferror`, then purges. It returns `d`, `e` on main and `Q`, `e` on the PR head. The wide result is already present on main. The published console fixture covers one byte of pushback, so the expected wide-character behavior still needs console qualification. [Review finding](https://github.com/boykopovar/AnyPS5/pull/27537#discussion_r4777217966)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#28693
No description provided.