Repository navigation
libobs: Free and reset after unknown shader calls - #3626
Conversation
A pass whose shader call names a function the effect doesn't define makes ep_makeshaderstring() return before it frees the call string and resets the written flags. The pass's pixel shader then leaves out the params the failed call named, and the call string leaks. The new test compiles the effect parser C into itself with the two shader-create calls renamed to recorders, so ep_compile() runs with no graphics device. It checks the pixel shader against a pass whose vertex call is NULL, and that nothing is left allocated after ep_free() and effect_free(). Both checks fail on master. Refs #3625.
When a pass's shader call names a function the effect doesn't define, ep_makeshaderstring() now frees the call string and resets the written flags before it returns, as it does after a call that succeeds. Only the shader with the bad call fails: the pass's other shader declares the params that call named again, and the call string no longer leaks. Fixes #3625. Local-Gate: v1 tree=6ad2c637b4895e52e61ea1c2285eb74feadf04d1 secs=2198 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1793810969,"gate":"rust/all/fmt","host":"linux-x86_64","key":"c8e5b8c8ecb627702f6b239e667ab66355cf22d730a76cf2ff71a279148344e8","lane":"lint","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":69,"stamp":"330594638529efaafc9f1c81947b69bb","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"} Ci-Attestation: {"at":1793810969,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"c8e5b8c8ecb627702f6b239e667ab66355cf22d730a76cf2ff71a279148344e8","lane":"lint","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":69,"stamp":"fc150300d15eab2c09a7a0e0e297db05","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"} Ci-Attestation: {"at":1793810969,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"ad3ccb3438a02ac0968638fa6bfcd194addd0e6352d97235f1762c42a04e1eb7","lane":"rust-test","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":142,"stamp":"6dd7ee2fa63da31fd7442f7648a647d5","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"} Ci-Attestation: {"at":1793810969,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"89034ad58ee31e6f4f7f96472ce0887950ee541c232aa87b42e0438dd874b4b6","lane":"cross","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":84,"stamp":"79ed599d0bf6dd30a4cf9fe931077638","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"} Ci-Attestation: {"at":1793810969,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"89034ad58ee31e6f4f7f96472ce0887950ee541c232aa87b42e0438dd874b4b6","lane":"cross","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":84,"stamp":"437df2674667fc47a9ff02d4de5df647","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"} Ci-Attestation: {"at":1793810969,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"89034ad58ee31e6f4f7f96472ce0887950ee541c232aa87b42e0438dd874b4b6","lane":"cross","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":84,"stamp":"790b5f7a391670abd05ef0dc52e65b57","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"} Ci-Attestation: {"at":1793810969,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"89034ad58ee31e6f4f7f96472ce0887950ee541c232aa87b42e0438dd874b4b6","lane":"cross","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":84,"stamp":"8e47c826caa16acf6326bffa25dbc489","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"} Ci-Attestation: {"at":1793810969,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"b9f7eb92939f575cf174379ee1017a99ce1b9f7454e4513da247fd7dd0648bb5","lane":"tier2-linux","parents":["817e4d9afbf5067cad0552c107e654c5f04a4fa0"],"secs":2198,"stamp":"ee204655a5f902de5bbba781e67aa299","tree":"6ad2c637b4895e52e61ea1c2285eb74feadf04d1","v":1,"via":"run"}
02e51c3 to
72ba354
Compare
|
Handed off to the coordinator |
|
Continuing the handed-off PR under maintainer direction: investigating merge-queue run 41928113205 in an isolated worktree. Current master extracted private effect-parser helpers into effect-parser-funcs.c.h; this test target omits that source. Reproducing the complete linker diagnostics locally before an additive build-definition fix. Existing commits and C test assertions will be preserved. |
|
Fixed the merge-queue Tier 2 link failure additively in 587382a, after merging master at 167da60 in 2feb30d. The original PR commits remain ancestors; no rebase or force-push. Root cause: #3627 extracted private parser helpers into The one-line fix adds that source to Local RED on 2feb30d, using the repository's container harness: OBS_TIER2_STAGE=build uv run --no-project rust/tools/linux-validate/run.pyExit 1. The full Local GREEN: the same full build command exited 0 after the one-line fix: Then, in a fresh invocation of the same LD_LIBRARY_PATH=/build/tree/libobs-c-reference ctest --test-dir /build/tree -V -R '^test_effect_parser_shader_call$'
LD_LIBRARY_PATH=/build/tree/libobs ctest --test-dir /build/tree -V -R '^test_effect_parser_shader_call$'Repository configuration checks: PYTHONPATH=ci uv run --no-project -m unittest ci.test_build_groups ci.test_native_test_graph_slices ci.test_cmocka_windows_diagnostics ci.test_cmocka_rust_static_guard17 tests, OK. |
Fixes #3625
What and why
When a pass in an effect file names a vertex or pixel function the file doesn't define (a typo such as
vertex_shader = VSDefualt(pos);),ep_makeshaderstringreturns early after it has written the declarations of the params the call names. That return skips the two lines the success path ends with:dstr_free(&call_str): the call string leaks every time the effect loads;ep_reset_written(ep): those params stay marked as written, so the pass's next shader (and every later one, until a call succeeds) leaves their declarations out. The pixel shader then fails with undeclared-identifier errors that point away from the real mistake.The vertex shader failing is expected. This PR makes the unknown-function return free the call string and reset the flags, the same as the success path, so only the shader with the typo fails and nothing leaks.
The fix is in C: the shader writer's Rust port waits on the function parser port and the writer's extraction. When it is ported it keeps this behaviour, with no intentional difference.
No upstream issue.
RED → GREEN
RED commit: 817e4d9 adds
test_effect_parser_shader_call, which compiles the effect parser C into itself withgs_vertexshader_createandgs_pixelshader_createrenamed to recorders that keep the shader text and return NULL, soep_compileruns with no graphics device. On mastertest_unknown_vertex_call_resets_writtenfails (the pixel shader is missinguniform float4 color;) andtest_unknown_vertex_call_freesfails (1 != 0: one allocation left afterep_freeandeffect_free); the controltest_null_vertex_callpasses.GREEN:
test_effect_parser_shader_callpasses 3/3 on the C build, hybrid libobs andlibobs-c-reference. Tier 2 in full: 730/730 on hybrid and 730/730 onlibobs-c-reference, 3 skipped on each (test_pulse_default_follow,test_v4l2_vivid_replug,test_v4l2_vivid_stall: no matching device),test_source_monitor_only_loadleft out (it hangs with no sound server); thenative-graphicstests, which load the real effects through this code with a GL device, 44/46 on all three builds with the other two being audio tests that time out with no sound server and pass when run alone. The exported symbol sets are identical on the C, hybrid and c-ref builds (1767 each).--test-diff: 6534 run, 6534 passed, 6 skipped.--lane lintand--lane cross: every step passes except the Dylint step, which can't run on the local host (no driver for the pinned nightly); MSVC clippy with--all-targetspasses. Runs were on 96c0a284e.Real app (UI, protocol output or logging changes): the Linux app (
obs-studio-rust-gui --multi, headless under Xvfb on llvmpipe, a fresh profile, no audio output), started with a copy of its data where libobs's ownrepeat.effect, which loads at startup, has the typovertex_shader = VSDefualt(vert_in, image);. It ran 25 s and was quit with SIGINT, once with master's libobs and once with this branch's, with nothing else changed. Master's log:This branch's log:
Only the shader with the typo fails, the pixel shader's misleading errors are gone, and nothing leaks.
Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC