• Bug#1101728: obs-studio: obs coredumps with message "double free or cor

    From Eriberto Mota@21:1/5 to All on Fri Apr 25 14:30:01 2025
    This is a multi-part message in MIME format.

    Control: tags 1101728 patch

    Dear maintainer,

    The attached patch fixes this issue. I will send an NMU with
    5 days of delay soon.

    Cheers,

    Eriberto

    Description: linux-v4l2: Fix virtual camera start failure
    Add function that tries to reset v4l2loopback output for module versions
    from 0.12.5 to 0.12.7. If successful, then set flag that STREAMON and
    STREAMOFF are necessary each time the device is opened/closed.
    Author: stephematician <steph.fn.contact@proton.me>
    Origin: https://github.com/obsproject/obs-studio/commit/12c6feb
    Bug: https://github.com/obsproject/obs-studio/issues/11891
    Bug-Debian: https://bugs.debian.org/1101728
    Bug-Debian: https://bugs.debian.org/1101351
    Reviewed-By: Joao Eriberto Mota Filho <eriberto@debian.org>
    Last-Update: 2025-04-25
    --- obs-studio-30.2.3+dfsg.orig/plugins/linux-v4l2/v4l2-output.c
    +++ obs-studio-30.2.3+dfsg/plugins/linux-v4l2/v4l2-output.c
    @@ -15,6 +15,7 @@ struct virtualcam_data {
    obs_output_t *output;
    int device;
    uint32_t frame_size;
    + bool use_caps_workaround;
    };

    static const char *virtualcam_name(void *unused)
    @@ -111,11 +112,54 @@ static void *virtualcam_create(obs_data_
    return vcam;
    }

    +bool try_reset_output_caps(const char *device)
    +{
    + struct v4l2_capability capability;
    + struct v4l2_format format;
    + int fd;
    +
    + blog(LOG_INFO, "Attempting to reset output capability of '%s'", device);
    +
    + fd = open(device, O_RDWR);
    + if (fd < 0)
    + return false;
    +
    + format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    + if (ioctl(fd, VIDIOC_G_FMT, &format) < 0)
    + goto fail_close_reset_caps_fd;
    +
    + if (ioctl(fd, VIDIOC_S_FMT, &format) < 0)
    + goto fail_close_reset_caps_fd;
    +
    + if (ioctl(fd, VIDIOC_STREAMON, &format.type) < 0)
    + goto fail_close_reset_caps_fd;
    +
    + if (ioctl(fd, VIDIOC_STREAMOFF,