Repository navigation
test: Fix the force_camera race in test_v4l2_busy_signal's fake libv4l2 - #997
Merged
Merged
Conversation
A new holder variant closes the device on SIGTERM and then takes 300 ms to exit, holding open the window machine load opens in the plain holder: fds closed, not yet a reapable zombie. The plugin sees the device free, but the fake libv4l2 still calls the holder alive (waitpid WNOHANG returns 0) and answers EBUSY, so the reopen fails. This is the intermittent force_camera_closes_the_holder_and_opens_the_camera failure, made deterministic. Refs #953
holder_alive() called the holder alive whenever waitpid(WNOHANG) returned 0, including the window after SIGTERM where the holder has closed its fds but is not yet a reapable zombie. The plugin's /proc scan already sees the device free there, so the reopen got EBUSY and force_camera_closes_the_holder_and_opens_the_camera failed under load. The fake now treats the device as busy only while /proc/<pid>/fd still has the camera open (the plugin's own view), and otherwise waits for the exiting holder, so its SIGTERM status is recorded deterministically. Fixes #953
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.
Fixes #953.
Cause (test fixture, not the plugin): the fake
libv4l2intest_v4l2_busy_signal.canswered EBUSY whilewaitpid(holder, WNOHANG) == 0. After Force Camera's SIGTERM, the holder closes its fds before it becomes a reapable zombie. The plugin's/procscan sees the device free in that window (releasedis true), but the reopen'swaitpid(WNOHANG)can still return 0, so the fake said busy,fake.holderkept the pid, andforce_camera_closes_the_holder_and_opens_the_camerafailed with<pid> != 0. Machine load (Tier 2-j4) widens the window.RED (
test: Force Camera must reopen while the holder is still exiting): a holder variant that, on SIGTERM, closes the device and then takes 300 ms to exit, holding that window open every time. New caseforce_camera_opens_while_the_holder_is_still_exiting. Locally it failed with10148 != 0attest_v4l2_busy_signal.c:344(thefake.holder == 0check): the flake's signature, made deterministic. The existing cases still pass.GREEN (
test: The fake libv4l2 frees the camera when its holder lets go): the fake treats the device as busy only while/proc/<pid>/fdstill has the camera open (the plugin's own view). Otherwise it waits for the exiting holder, so its SIGTERM status is recorded deterministically. Theignore_termholder keeps its fd and stays busy.Local:
./lintok; Tier 2 OFF:test_v4l2_busy_signalpasses, new case included. That run (machine heavily loaded) also hittest_async_delay_audio,test_deinterlace_2x_field_orderandtest_media_restart_stale_frame, the real-time media flakes of #838. The harness stops there, so the v4l2 repeats and the ON build were not run locally; PR CI runs both.