You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
oracle os_utf8_to_wcs_ptr stub returns 0 for every input and is reachable from dstr_to_wcs #84
This stub answers "conversion succeeded" with 0 for every input, which is
both a wrong return value and a wrong *pstr.
It is not dead code. libobs/util/dstr.c:727 dstr_to_wcs calls os_utf8_to_wcs_ptr, and rust/obs-c-oracle/build.rs:35 compiles dstr.c into the same oracle, so oracle_dstr_to_wcs links against this stub.
The reason it has not caused a failure yet is only that no test declares or
calls oracle_dstr_to_wcs today.
Why it matters
This is the same failure mode that produced #79, and it is the more dangerous
of the two. In #79 the os_fopen stub was stricter than libobs, so the
differential test silently certified a fiction and a port author imported that
fiction into file_serializer.rs with a comment asserting it as libobs
behaviour. Here, the first port that pulls in a dstr-dependent source path and
runs it through the oracle will see os_utf8_to_wcs_ptr always fail, will
conclude "C's conversion fails", and will encode a refusal into the port — again
matching the stub rather than libobs/util/platform.c:445-456.
Note the two directions of failure differ: for os_fopen the stub made the
oracle stricter than libobs; for os_utf8_to_wcs_ptr the stub makes every
conversion fail, including ones libobs performs successfully.
with os_utf8_to_wcs delegating to a MultiByteToWideChar(CP_UTF8, 0, …)-based utf8_to_wchar on Windows, as now done for os_fopen in #82.
Suggested follow-up hardening
Add a #[test] in the oracle crate (or an assertion in a dstr port's Tier 1)
that pins oracle_dstr_to_wcs against a known string on Windows, so a future
stub regression cannot pass silently. That is cheap and closes exactly this
class of "oracle lies, test agrees, port is wrong".
I'm taking this one, with a PR shortly. The plan: compile the real util/utf8.c into the oracle and copy the platform.c conversions verbatim. That also fixes the other two zero stubs next to it, os_mbs_to_utf8_ptr and wchar_to_utf8. Add a test that pins dstr_to_wcs (and dstr_from_wcs/dstr_from_mbs) against known strings.
Activity
b7216309-jpg commentedon Oct 10, 2026
I'm taking this one, with a PR shortly. The plan: compile the real
util/utf8.cinto the oracle and copy theplatform.cconversions verbatim. That also fixes the other two zero stubs next to it,os_mbs_to_utf8_ptrandwchar_to_utf8. Add a test that pinsdstr_to_wcs(anddstr_from_wcs/dstr_from_mbs) against known strings.rust/obs-c-oracle: Pin dstr.c's conversions in the oracle (RED)
rust/obs-c-oracle: Replace the dstr conversion stubs with libobs code
obs-c-oracle: Compile the real platform.c instead of four hand copies…
obs-c-oracle: Compile the real platform.c instead of four hand copies…
obs-c-oracle: Compile the real platform.c instead of four hand copies…
obs-c-oracle: Compile the real platform.c instead of four hand copies…
obs-c-oracle: Compile the real platform.c instead of four hand copies…