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
Tracking the platform.c item of #153. The OS-specific platform-nix.c and platform-windows.c are not part of this; they're the next item on #153.
platform.c is 834 lines and mixes unrelated groups, so it comes in slices, one PR each. Each slice starts with its functions moved verbatim into their own .c file (a behavior-neutral commit, as the testing policy asks for partial-file ports), then C characterization, RED, GREEN, and parity against the oracle:
Conversions:os_mbs_to_wcs, os_utf8_to_wcs, os_wcs_to_mbs, os_wcs_to_utf8, their _ptr forms, os_utf8_to_mbs_ptr and os_mbs_to_utf8_ptr. These are over the existing utf8 port and the C locale functions (mbstowcs/wcstombs). On Windows they need the utf8.c Windows branch, which isn't ported yet. Done well, this also replaces the oracle copies in platform_conv_host.c (see bug: Oracle stand-ins in test_stubs.c can diverge from libobs #145).
Numbers:os_strtod and os_dtostr (decimal point independent of the locale).
Files:os_wfopen/os_fopen, os_fgetsize, os_stat, os_fseeki64/os_ftelli64, os_fread_mbs/os_fread_utf8, os_quick_read_*/os_quick_write_* (including _safe) and os_get_file_size.
Directories:os_mkdirs.
Filenames:os_generate_formatted_filename.
Time:os_nstime_to_timespec.
Tier 2 gates: test_platform, test_os_path and test_formatted_filename. I can run Windows (MSVC) and Linux (an Ubuntu 26.04 VM) locally. Slices go in the order above unless review prefers otherwise; I'll open each one here before starting it.
libobs/util: Treat unconvertible text as a failed mbs conversion #263 (C fix first):os_mbs_to_wcs and os_wcs_to_mbs took (size_t)-1 from mbstowcs/wcstombs as a length. The _ptr forms then called bmalloc(0), which crashes; it's reachable from X11 window titles in xcomposite. Separately, a buffer too small for the text got its NUL written one past the end.
The Windows branch of util/utf8.c (MultiByteToWideChar/WideCharToMultiByte), so utf8_to_wchar and wchar_to_utf8 exist in Rust on every OS. The conversions need it on Windows.
The port of the twelve conversion functions, with parity against the fixed C.
FYI for the platform.c slices: os_generate_formatted_filename (libobs/util/platform.c:697) uses non-reentrant localtime(), the same race as #132 (log timestamps from other threads share the static buffer). Worth localtime_r/localtime_s in the C and the Rust port. I left it alone because this issue is claimed.
@b7216309-jpg are you still on the platform.c slices? Since #263 and #267 landed, I don't see a PR for slice 1 (conversions). If you're busy, I can take slice 2 (numbers: os_strtod, os_dtostr), which doesn't overlap with the conversions. Same flow: a verbatim move into its own .c, characterization, RED, GREEN, parity. I won't start unless you say so or there's no reply by tomorrow; slice 1 stays yours either way.
Slice 2 (numbers) done: #825 moved os_strtod/os_dtostr into util/platform-number.c, and #826 ported it to obs-util (platform_number.rs, Tier 1 + Tier 3 against the real C, dropped under ENABLE_RUST_LIBOBS=ON). The config-file port now shares the same parser and formatter, and the oracle compiles the real file instead of copies (#145).
Intentional difference: Rust always uses .; C swaps in the LC_NUMERIC decimal point, so only text already written with a non-. locale point ("1,5") reads differently.
Releasing my claim on slice 2. Left on this issue: slice 1 (conversions, @b7216309-jpg) and slices 3+ (files, directories, …).
Behavior-neutral: move them verbatim from platform.c into libobs/util/platform-file.c.h; add cmocka characterization where test_platform/test_os_path don't cover them.
RED: Rust stubs + Tier 1; GREEN: port to obs-util (Windows paths under src/platform/windows/), Tier 3 parity against the oracle, ENABLE_RUST_LIBOBS guard.
Decisions: Windows os_fopen keeps calling the C os_utf8_to_wcs_ptr (slice 1, @b7216309-jpg's) until slice 1 is ported, so the two slices don't overlap.
Checked on master 5074635e3: each slice has an ENABLE_RUST_LIBOBS C ABI export under libobs/cmake/rust-exports.d/obs-util-platform_{conversions,number,file,mkdirs,filename,time}.txt, and the Tier 2 gates named in the tracker (test_platform, test_os_path, test_formatted_filename) are the ones CI runs for them. The tracker's step text is stale per slice 1's note: the original PRs moved each group into its own platform-*.c first, so the calls are per-file rather than through one platform.c.
Remaining on #153: pipe-windows.c, platform-nix.c/platform-windows.c, and the threading pair; the #145 oracle stand-ins were also folded into slice 1. #153's checkbox is ticked.
Activity
b7216309-jpg commentedon Oct 11, 2026
Slice 1 (conversions) is under way:
os_mbs_to_wcsandos_wcs_to_mbstook(size_t)-1frommbstowcs/wcstombsas a length. The_ptrforms then calledbmalloc(0), which crashes; it's reachable from X11 window titles in xcomposite. Separately, a buffer too small for the text got its NUL written one past the end.util/utf8.c(MultiByteToWideChar/WideCharToMultiByte), soutf8_to_wcharandwchar_to_utf8exist in Rust on every OS. The conversions need it on Windows.zackees commentedon Oct 13, 2026
FYI for the platform.c slices:
os_generate_formatted_filename(libobs/util/platform.c:697) uses non-reentrantlocaltime(), the same race as #132 (log timestamps from other threads share the static buffer). Worthlocaltime_r/localtime_sin the C and the Rust port. I left it alone because this issue is claimed.zackees commentedon Oct 14, 2026
@b7216309-jpg are you still on the platform.c slices? Since #263 and #267 landed, I don't see a PR for slice 1 (conversions). If you're busy, I can take slice 2 (numbers:
os_strtod,os_dtostr), which doesn't overlap with the conversions. Same flow: a verbatim move into its own.c, characterization, RED, GREEN, parity. I won't start unless you say so or there's no reply by tomorrow; slice 1 stays yours either way.zackees commentedon Oct 15, 2026
Taking slice 2 (numbers:
os_strtod,os_dtostr), no reply in 24 h. Slice 1 (conversions) stays with @b7216309-jpg.Claiming: #262 slice 2
os_strtod/os_dtostr(with their locale helpers) verbatim fromplatform.cintolibobs/util/platform-number.c.test_dtostr_exponentfrom util: Fix os_dtostr leaving exponent tail digits behind #796 already covers the exponent rows).ENABLE_RUST_LIBOBSguard.First PR (step 1–2) today.
util: Test os_strtod and os_dtostr against Rust stubs (RED)
util: Port os_strtod and os_dtostr to obs-util (GREEN)
util: Link the C oracle into the os_strtod/os_dtostr Tier 1 test
util: Test os_strtod and os_dtostr against Rust stubs (RED)
util: Port os_strtod and os_dtostr to obs-util (GREEN)
util: Link the C oracle into the os_strtod/os_dtostr Tier 1 test
zackees commentedon Oct 15, 2026
Slice 2 (numbers) done: #825 moved
os_strtod/os_dtostrintoutil/platform-number.c, and #826 ported it toobs-util(platform_number.rs, Tier 1 + Tier 3 against the real C, dropped underENABLE_RUST_LIBOBS=ON). The config-file port now shares the same parser and formatter, and the oracle compiles the real file instead of copies (#145).Intentional difference: Rust always uses
.; C swaps in theLC_NUMERICdecimal point, so only text already written with a non-.locale point ("1,5") reads differently.Releasing my claim on slice 2. Left on this issue: slice 1 (conversions, @b7216309-jpg) and slices 3+ (files, directories, …).
util: Port os_strtod and os_dtostr to obs-util (obs-rust#826)
util: Move os_strtod and os_dtostr into platform-number.c (obs-rust#825)
swilk19 commentedon Oct 18, 2026
Claiming: #262 slice 3 (files:
os_wfopen/os_fopen,os_fgetsize,os_stat,os_fseeki64/os_ftelli64,os_fread_mbs/os_fread_utf8,os_quick_read_*/os_quick_write_*incl._safe,os_get_file_size)platform.cintolibobs/util/platform-file.c.h; add cmocka characterization wheretest_platform/test_os_pathdon't cover them.obs-util(Windows paths undersrc/platform/windows/), Tier 3 parity against the oracle,ENABLE_RUST_LIBOBSguard.Decisions: Windows
os_fopenkeeps calling the Cos_utf8_to_wcs_ptr(slice 1, @b7216309-jpg's) until slice 1 is ported, so the two slices don't overlap.First PR (step 1) within a day.
30 remaining items
util: Test the platform string conversions against a Rust stub
util: Port the platform string conversions to obs-util
util: Compare the platform string conversions with the C
util: Document the conversions port and benchmark it against the C
util: Port the platform string conversions to obs-util (obs-rust#1874)
zackees commentedon Oct 25, 2026
Triage: the slice tracker for platform.c (item of #153); slice 1 is up as #1874. Labelling it
tracker.zackees commentedon Oct 30, 2026
Tracker complete: every slice of
platform.chas landed inobs-util, so closing.os_mbs_to_wcs,os_utf8_to_wcs,os_wcs_to_mbs,os_wcs_to_utf8and_ptrformsplatform_conversions.rs)os_strtod,os_dtostrplatform_number.rs)os_wfopen/os_fopen, sizes, stat, seek/tell, quick read/writeplatform_file.rs)os_mkdirsplatform_mkdirs.rs)os_generate_formatted_filenameplatform_filename.rs)os_nstime_to_timespecplatform_time.rs)Checked on master
5074635e3: each slice has anENABLE_RUST_LIBOBSC ABI export underlibobs/cmake/rust-exports.d/obs-util-platform_{conversions,number,file,mkdirs,filename,time}.txt, and the Tier 2 gates named in the tracker (test_platform,test_os_path,test_formatted_filename) are the ones CI runs for them. The tracker's step text is stale per slice 1's note: the original PRs moved each group into its ownplatform-*.cfirst, so the calls are per-file rather than through oneplatform.c.Remaining on #153:
pipe-windows.c,platform-nix.c/platform-windows.c, and the threading pair; the#145oracle stand-ins were also folded into slice 1.#153's checkbox is ticked.