Repository navigation
Description
Root cause
The Tier 3 oracle's Windows path stub is stricter than libobs.
rust/obs-c-oracle/oracle/file_serializer_host.c:31-59:
static wchar_t *utf8_to_wide(const char *path)
{
...
n = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path, -1, NULL, 0); /* :38 */
if (n <= 0)
return NULL;so the oracle's os_fopen fails for any path that is not valid UTF-8.
libobs does not. os_fopen (libobs/util/platform.c:55-71) calls
os_utf8_to_wcs_ptr (platform.c:445-456) and discards its return value;
the conversion ends at utf8_to_wchar (libobs/util/utf8.c:47), which calls
ret = MultiByteToWideChar(CP_UTF8, 0, in, i_insize, out, (int)outsize);dwFlags = 0, no MB_ERR_INVALID_CHARS. On Vista and later that substitutes
U+FFFD for invalid sequences and returns > 0. So a non-UTF-8 path is attempted,
never rejected; the only observable outcome is that the mangled path normally
does not exist, os_fopen returns NULL, and the caller sees the usual failure.
Impact
Tier 3 differential parity on Windows compares the Rust shims against a stub
that is stricter than production libobs, so it can certify port behaviour that
differs from the real library. It already has, twice:
-
rust/obs-util/src/file_serializer.rs:47-52returnsNonefrom
path_from_byteswithout attempting the open when the path is not valid
UTF-8, justified by the comment at:49("os_fopenrejects a path that is
not valid UTF-8"), which is false. This makesfile_input_serializer_init,
file_output_serializer_initandfile_output_serializer_init_safeall
returnfalsewhere libobs would attempt the U+FFFD-substituted path. Note
the behaviour matches the oracle stub, notlibobs/util/platform.c. -
The same false premise produced the "C's UTF-8→UTF-16 conversion fails the
open" note recorded in PR rust: Port util/config-file.c to obs-util #77, now at
rust/obs-util/tests/config_file_parity.rs:20-23. The config-file port's
path_from_bytes(rust/obs-util/src/config_file.rs:764-770, unmerged)
does substitute U+FFFD, so these two ports take opposite approaches to the
identical conversion.
The existing coverage does not catch it: non_utf8_filename_matches_oracle is
#[cfg(unix)] (rust/obs-util/tests/file_serializer_parity.rs:754), so it
never runs on the Windows CI lane where the stub differs.
Reproducer
Windows only. In file_serializer_parity.rs add an un-#[cfg(unix)]-gated
case that creates a file named with the U+FFFD-substituted form of a non-UTF-8
path (e.g. "scratch\\\u{FFFD}.ini"), then calls both
oracle_file_input_serializer_init and file_input_serializer_init with
b"/tmp/\xff\xfe.ini"-style bytes. Expected: both open it. Actual with the
current stub: the oracle returns false immediately, and the Rust shim also
returns false, so they agree — and are both wrong about production libobs.
Suggested fix
- Remove
MB_ERR_INVALID_CHARSfromutf8_to_wide()
(rust/obs-c-oracle/oracle/file_serializer_host.c:38,44) so the oracle
matchesutf8_to_wchar's flags-0, U+FFFD-substituting behaviour. Remove the
#[cfg(unix)]gate on the non-UTF-8 test so it runs on Windows; a
rust/obs-c-oracle-only change cannot be validated on this host. - Then fix the port to match:
rust/obs-util/src/file_serializer.rs:47-52
should substitute U+FFFD like the config-file port, with the comment
corrected — or the refusal should be recorded as an intentional difference in
the test file and the tracking issue as the testing policy requires. Either
way the two ports should agree. - Separately,
os_utf8_to_wcs_ptrat
rust/obs-c-oracle/oracle/file_serializer_host.c:167-171returns NULL/0 for
every input, which is also unfaithful. Nothing in the current oracle TU set
calls it, but it will silently mislead the next port that pulls in a
dstr-dependent source.
The whole correctness argument for these ports is "the differential test proved
the Rust matches C". With this stub, on Windows, that argument is false for path
handling.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rust/obs-c-oracle: Replace the dstr conversion stubs with libobs code
fix(oracle): match libobs U+FFFD substitution in the os_fopen stub (RED)
fix(obs-util): substitute U+FFFD for non-UTF-8 paths on Windows (GREEN)
chriscoveries commentedon Oct 10, 2026
Closed as fixed: PR #82 makes the oracle's UTF-8 -> UTF-16 conversion match libobs (flags 0, U+FFFD substitution) instead of failing on invalid UTF-8.