From patchwork Tue Oct 15 21:26:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Niebur X-Patchwork-Id: 15776 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 6FDC2449C73 for ; Wed, 16 Oct 2019 00:26:50 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 44C2C68A1E1; Wed, 16 Oct 2019 00:26:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3754A689F31 for ; Wed, 16 Oct 2019 00:26:43 +0300 (EEST) Received: by mail-io1-f65.google.com with SMTP id w12so49762695iol.11 for ; Tue, 15 Oct 2019 14:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thuuz-com.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=PUDm0A0CyLmOAj7FYQKZUq4uSamWhaCroQSwmPx4CxI=; b=Q0FJLBY16OYNvu1fC1YHAjjGPrPX9k+AeN/XjwXI7NNL0LwgbdVWNbup4B8S6Kn975 pF+KCr0INzECZ7LerZcXVAS2A4zC7Cdp5erQdDj1wQlMzAfahK64iiXEIPbkyQzLYWW9 CQsxIn0bMZezWrxeRCBsMdod2mRlqBdSs7zZP/Y+TvYsCBmvp7G9mC23nLd4oakaKoUW rSpmDkC/OntX7kFxz+aZzyC4lYZQ8JXI8m1Bnc67+tVlTWL6BpU2I+wnrCLbqaLbW4oV s7NHF3llvyG804pmyZoLZliy30dBL2qRM1jRETUcLlX9Bn0LIv2cHnK5k/ZC6jOO5Ozo mASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=PUDm0A0CyLmOAj7FYQKZUq4uSamWhaCroQSwmPx4CxI=; b=Ky9xdiUm/nHNFmt39k6K2WQTDvZRUDIC6PHnrZIvOkLQ/W3sNPwRsCkdGQPUd7KzKp wo+Y6qHFzKYZl2G4PeewELZ9xoyhb0bBTVhguREf+u8otfTrvKNs37lEutqxs9cqJN5g e6MaNu2qzMbZ3Q7f1DUJz/4OELees8YHcjvRTY6fXjshwxrtdXdckDTQCxixHaCIOHyI DZBIT2mpdjiSZ03CciJfdB/MBeN9pyQl0ZOXj4E+onA6ZJ51GfXLiDHRxLBd5y2i7P/j gESdxG8jZRd7hQQ+UqV9k2/m46nv1NqE33MchMh2ZJbQtQ2rBwBmgKZgD8QqmbbLxOu+ hXoA== X-Gm-Message-State: APjAAAXqW6xVQKvui14RMsb/wxK+vuIGyluoxTVKsRb/5V7WYZGMksSf A8eMcSkIm0sa0ZWLK/FyzH1Itd8Kpzs7vQ== X-Google-Smtp-Source: APXvYqz/IOItZco3OpEntevZcvlQOlfTpssqziSnELbb5KGhnAgyw6TeD62HeMr6tFFF3n1SToUBXg== X-Received: by 2002:a92:de02:: with SMTP id x2mr8660298ilm.168.1571174801637; Tue, 15 Oct 2019 14:26:41 -0700 (PDT) Received: from [10.1.10.66] (c-67-174-183-116.hsd1.co.comcast.net. [67.174.183.116]) by smtp.gmail.com with ESMTPSA id v17sm3658208ill.76.2019.10.15.14.26.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Oct 2019 14:26:41 -0700 (PDT) From: Mark Niebur Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3594.4.19\)) Date: Tue, 15 Oct 2019 15:26:40 -0600 References: To: FFmpeg development discussions and patches In-Reply-To: Message-Id: <5A36697B-72BA-498C-A172-B8218AE086A5@thuuz.com> X-Mailer: Apple Mail (2.3594.4.19) Subject: Re: [FFmpeg-devel] segfault in af_afade.c::activate X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" I just checked out master and I see the fix you mentioned. This does not completely fix acrossfade for me. I also had to apply the following patch: Thanks, Mark > On Oct 15, 2019, at 2:26 PM, Paul B Mahol wrote: > > On 10/15/19, Mark Niebur wrote: >> Hello, >> I'm trying to debug an issue I'm seeing where the filter "acrossfade" >> produces a segfault. This seemingly only happens in docker containers, and >> I am seeing it when running a rather large filter chain. I'm trying to get >> to the bottom of it, but it would be really helpful to understand the >> context around how libavfilter fills the filter input fifos. This is the >> code where I'm seeing the segfault: >> 449 AVFrame *in = NULL, *out, *cf[2] = { NULL }; >> ... >> 474 if (ff_inlink_queued_samples(ctx->inputs[0]) > s->nb_samples) { >> 475 // consume some samples - this is not a crossfade overlap >> 486 } else if (ff_inlink_queued_samples(ctx->inputs[1]) >= >> s->nb_samples) { >> 487 if (s->overlap) { >> 488 out = ff_get_audio_buffer(outlink, s->nb_samples); >> 489 if (!out) >> 490 return AVERROR(ENOMEM); >> 491 // NO CHECK IS DONE HERE THAT ENOUGH SAMPLES ARE PRESENT >> 491 // In our case, there are 0 samples, so >> ff_inlink_consume_samples returns early and does not set cf[0] >> 492 ret = ff_inlink_consume_samples(ctx->inputs[0], >> s->nb_samples, s->nb_samples, &cf[0]); >> 493 if (ret < 0) { >> 494 av_frame_free(&out); >> 495 return ret; >> 496 } >> 497 // SEGFAULT HERE >> 498 ret = ff_inlink_consume_samples(ctx->inputs[1], >> s->nb_samples, s->nb_samples, &cf[1]); >> 499 if (ret < 0) { >> 500 av_frame_free(&out); >> 501 return ret; >> 502 } >> >> How does avfilter add samples to an inlink? Does it just fill it randomly >> or will it fill input 0 completely and then move on to input 1, 2, 3? Even >> when I fix this segfault by ensuring that >> ff_inlink_queued_samples(ctx->inputs[0]) == s->nb_samples, I will still get >> additional segfaults in the acrossfade code where ff_inlink_consume_samples >> returns 0 and does not set the frame pointer. > > I think this was just reported and fixed very recently. > >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c index 195fb65..446aa0a 100644 --- a/libavfilter/af_afade.c +++ b/libavfilter/af_afade.c @@ -459,11 +459,11 @@ static int activate(AVFilterContext *ctx) } else if (ff_inlink_acknowledge_status(ctx->inputs[1], &status, &pts)) { ff_outlink_set_status(ctx->outputs[0], status, pts); return 0; - } else { - if (ff_outlink_frame_wanted(ctx->outputs[0]) && !in) { + } else if (!in) { + if (ff_outlink_frame_wanted(ctx->outputs[0])) { ff_inlink_request_frame(ctx->inputs[1]); - return 0; } + return 0; } in->pts = s->pts; s->pts += av_rescale_q(in->nb_samples,