Bug 103417

Summary: gstreamer nvh264enc deadlock and crashed
Product: Spice Reporter: alan <bochuan.ding>
Component: serverAssignee: Spice Bug List <spice-bugs>
Status: RESOLVED MOVED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description alan 2017-10-23 12:17:27 UTC
Spice server version 0.13.90
Host OS: Ubuntu 16.04
Guest OS: Windows 7

For hardware accelerate, I use GStreamer nvh264enc in place of xh264enc. However, it often get deadlock when GStreamer get restarted. I debugged the gstreamer plugin nvenc and I find the problem in the free_pipeline() and create_pipeline()。 Because there is no mutex lock to protect the process create/free pipeline,when the pipeline status switched in a short time,e.g start -> stop -> start, the nvenc would be in unknown status. In my case, it causes the deadlock inside the nvenc plugin.

I try to fix this bug in a simple way. In the configure_pipeline(), call free_pipeline() before create_pipeline(). This will make sure that we do free the resource of pipeline and it's safe even if the encoder->pipeline is NULL.

The source code is below. Here is the only way to call create_pipeline() except the gstreamer_encoder_new(), but it's like a initialized constructor, so we just take care about the configure_pipeline() which takes responsibility for switching the status of the pipeline.

static gboolean configure_pipeline(SpiceGstEncoder *encoder)
{
    if (!encoder->set_pipeline) {
        return TRUE;
    }

    free_pipeline(encoder->pipeline);

    if (!encoder->pipeline && !create_pipeline(encoder)) {
        return FALSE;
    }
    ...
}


I can't guarantee that it doesn't bring in other bugs. I think there should be a more grace method to fix this problem.
Comment 1 GitLab Migration User 2018-06-03 10:15:17 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/spice/spice-server/issues/15.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.