Fix spurious fd closing (os_process and v4l2)#13198
Open
hoshinolina wants to merge 2 commits intoobsproject:masterfrom
Open
Fix spurious fd closing (os_process and v4l2)#13198hoshinolina wants to merge 2 commits intoobsproject:masterfrom
hoshinolina wants to merge 2 commits intoobsproject:masterfrom
Conversation
The sequence should be the same for every fd: - Close the parent end of the pipe - If the child end of the pipe is not the intended fd already, - Dup it over - And close the old fd This fixes a double-close() in the read path (which is fairly harmless since it happens in the child, but sticks out in strace), some fd leakage, and the stderr-already-is-2 case.
kkartaltepe
approved these changes
Mar 7, 2026
RytoEX
requested changes
Mar 8, 2026
Make sure to use the invalid fd -1 when the output is not opened, and only close valid fds. If fd 0 is closed, then this closes stdin. The second time this happens, some other important fd will have become fd 0, breaking something. This causes random things to break (browser/CEF in reports, but really it could be anything) as the wrong fds get closed.
04634a9 to
d86891b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix two bugs causing the wrong file descriptors to be closed. The os_process one is harmless but was discovered while debugging this. The v4l2loopback one is actively causing crashes.
Motivation and Context
User bug report of CEF crashes on profile switching or when closing OBS. Turns out CEF/Chromium validates fd reuse and actively asserts when something wonky happens.
How Has This Been Tested?
Tested locally, planning to push bugfix to Fedora shortly.
Types of changes
Checklist: