Skip to content

fix(obs-util): config_file duplicate section/key lookup follows uthash (#681) - #726

Merged
zackees merged 2 commits into
masterfrom
fix/681-config-dup-lookup
Oct 14, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/681-config-dup-lookup

Conversation

@zackees

@zackees zackees commented Oct 14, 2026

Copy link
Copy Markdown
Member

Fixes #681

C adds parsed sections and items with HASH_ADD_STR and finds them with HASH_FIND_STR. uthash prepends into bucket chains and relinks them when a chain reaches 10 entries, which reverses same-key order, so C can return an older duplicate. The port always picked the newest.

Sections and items now live in a private UtList (rust/obs-util/src/config_file/uthash_model.rs) that models uthash 2.3.0 as libobs uses it: HASH_SFH (libobs overrides HASH_FUNCTION; not Jenkins), 32 initial buckets, prepend on add, expansion trigger (expand_mult+1)*10, HASH_EXPAND_BUCKETS relink order with expand_mult / ineff_expands / noexpand, chain-order HASH_FIND, and table reset when the last entry is deleted. Iteration and save order are unchanged (insertion order, as C's hh.next list). Lookups, config_set_*, config_remove_value and config_has_user_value all go through the same find. No public API change.

Also removes the #681 exclusions from the config_ini_diff fuzz target and docs/rust-port/fuzzing.md.

RED: 5aaadf7

  • Tier 1 (tests/config_file.rs): duplicate_sections_follow_uthash_expansion, duplicate_keys_follow_uthash_expansion, duplicate_keys_set_and_remove_touch_the_found_entry fail (10 sections: C returns NULL, port returned "v"; 10 keys: C "v0", port "v9").
  • Tier 3 (tests/config_file_duplicates_parity.rs): all 5 tests fail on master (3 proptests over 1..40 duplicates with set/remove/has/get ops and saved-byte comparison, plus the 10-section repro and every count up to 40).

GREEN: 683afb4

  • soldr cargo test -p obs-util: all pass (parity file now also covers counts to 120 and hundreds of distinct and repeated keys).
  • Mutation check: changing the expansion threshold 10 to 11 makes all 5 original Tier 3 tests fail.
  • ./lint ok. rust/tools/linux-validate/run.sh: OFF and ON 208/208 ctest pass, exported symbols IDENTICAL (1766).
  • ci-lint local-gate run passed on all four lanes; head is stamped, pushed unchanged.

Not verified

  • Little-endian get16bits only (uthash's default on x86/arm64); big-endian hosts untested.
  • The config_ini_diff fuzz target edit was not compiled or run here (needs cargo-fuzz and nightly).
  • Only the config-file tables are modeled (sections, items, defaults); HASH_SORT is not used by config-file.c.

)

Sections and items now live in a UtList that reproduces uthash 2.3.0
(HASH_SFH, prepend into bucket, bucket expansion relink, noexpand) so
lookups, set, remove and has_user_value pick the duplicate C picks.
Drops the #681 exclusions from the config_ini_diff fuzz target.

Local-Gate: v1 tree=9c3e09f6471296185d9567a45fd376793118090e secs=382 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run
Ci-Attestation: {"at":1791982716,"gate":"rust/all/fmt","host":"linux-x86_64","key":"5ea7036a2f29042cad6c4ae89fee908813c7409af1edce59be5ff76a105bed10","lane":"lint","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":35,"stamp":"da7547d62810af8328a48e78d5deea3a","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"5ea7036a2f29042cad6c4ae89fee908813c7409af1edce59be5ff76a105bed10","lane":"lint","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":35,"stamp":"ceb1590ba02e0e9900b31117cb9f5676","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"95ccd8683f3f6956d13d7a6954733dd2ec5fc2b8324d7fddfc1adf01244f447c","lane":"rust-test","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":87,"stamp":"9cb2c4b8ffb6cb677a71fdae4545d60f","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"4b1692d5ed039797c451a9bcaacdadda092be6824b23a63690521625219b692a","lane":"cross","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":77,"stamp":"e7e9cdc3bce485631e43fd96db4e9851","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"4b1692d5ed039797c451a9bcaacdadda092be6824b23a63690521625219b692a","lane":"cross","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":77,"stamp":"bc6800ff87bf35bfbfde2b128751e8fa","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"4b1692d5ed039797c451a9bcaacdadda092be6824b23a63690521625219b692a","lane":"cross","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":77,"stamp":"687397b996063da7cee6dfe9bc6fbbdc","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"4b1692d5ed039797c451a9bcaacdadda092be6824b23a63690521625219b692a","lane":"cross","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":77,"stamp":"4ed12c29f2b389c4b3e8de8094362a5e","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"4b1692d5ed039797c451a9bcaacdadda092be6824b23a63690521625219b692a","lane":"cross","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":77,"stamp":"152e1225f08d0035debd00f57db8e9ea","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"4b1692d5ed039797c451a9bcaacdadda092be6824b23a63690521625219b692a","lane":"cross","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":77,"stamp":"2d907092fd4bb95ce903b8b583374966","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
Ci-Attestation: {"at":1791982716,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"6eba046c8357b16eb368cf32573659baf5d15281e50ce69137658e533a6a93e3","lane":"tier2-linux","parents":["5aaadf7a91a7a0643813c8718004a618ace2f228"],"secs":183,"stamp":"43f07e80541c7d0520455dc1bc746e24","tree":"9c3e09f6471296185d9567a45fd376793118090e","v":1,"via":"run"}
@zackees
zackees enabled auto-merge October 14, 2026 12:59
@zackees
zackees added this pull request to the merge queue Oct 14, 2026
Merged via the queue into master with commit 87731ce Oct 14, 2026
20 checks passed
@zackees
zackees deleted the fix/681-config-dup-lookup branch October 26, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug(obs-util): config-file duplicate section/key lookup diverges from C after uthash bucket expansion

1 participant