From patchwork Fri Jan 13 14:07:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Ronald S. Bultje" X-Patchwork-Id: 2212 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp212575vsb; Fri, 13 Jan 2017 06:37:08 -0800 (PST) X-Received: by 10.28.127.20 with SMTP id a20mr2782636wmd.15.1484318228370; Fri, 13 Jan 2017 06:37:08 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 124si651556wmz.95.2017.01.13.06.37.06; Fri, 13 Jan 2017 06:37:08 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D9D5768A3E8; Fri, 13 Jan 2017 16:36:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot0-f195.google.com (mail-ot0-f195.google.com [74.125.82.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4380668A3A7 for ; Fri, 13 Jan 2017 16:36:49 +0200 (EET) Received: by mail-ot0-f195.google.com with SMTP id 36so1209716otx.3 for ; Fri, 13 Jan 2017 06:36:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=h1fXI4fUwyEHzupmR6n12eqjqA8A6yfzaEHT/osUHJw=; b=aQvS4HB5eCIIQkHJ4IECOo+8NYyy2UnQy0e5xX5fMGuwyP/+khBgESY4xcyLZ8LF7o fuFtobRH+EQaMGyTEv5Vvlx1NhQUWmdkU5uAXIoR48LpKk2xjlF+BxmILBRKbuaFdBdD SHSqGhf4K4hAwpIq5fCzJPW2qA+ORonSuDsiMX5raSwBm9tFizQHl85VYRCJ2Qc2OBkv lhY5Q33WTsAe50uwenvYW7xS4Mad6oh+zixTO5xHA07InILEmfDqfNQbb1XA6dCOcFsR KYJS/Sf/mEM821HcL3ajkDKSd9E6fJ+pbS1IrKVNdo814PBHqwPBK4dYHzIgOw7/IXHI dL4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=h1fXI4fUwyEHzupmR6n12eqjqA8A6yfzaEHT/osUHJw=; b=RN+JP92g9qMLHSLhTuV4fLEwc/gkuVSoc2fW+/UE/UbvwBoOoviqmJkJJeIIQ+h2ks uwfkbLYorXcUovtdVgn2c/rfWMuzeNX8qaWur5M2TpjF3nF5NZE0cLERHFAUDTiYat7s InrBWiKPBBiabaq4ENDP2rD6BKnyEPlNV2zO8cBMvxy4IBtGo2IvzuTQu9T0aPRGvPDA Q5oOHqzeUZtMUZ7XqfbJWMDMNJ7c226joszXx940OQQ+U6ts6/m7afFIXcy4UNqrmnfO aCa5ZOLfe/9W8Y6xRiHdN7mevk7uh0sP+BLSsyO+r2JCEjAPXb1YqHuZJO3pXdm4iv9R nKKA== X-Gm-Message-State: AIkVDXKpwR0AMrKswCxSMNCA4L/Wk4FGb1E7qGL1Gs0JJQr8+/Zr/WbsW4QFBOx/rswKTvdZ4Za0Aj45bwvG9A== X-Received: by 10.157.13.23 with SMTP id 23mr9454423oti.264.1484316469391; Fri, 13 Jan 2017 06:07:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.13.170 with HTTP; Fri, 13 Jan 2017 06:07:48 -0800 (PST) Received: by 10.157.13.170 with HTTP; Fri, 13 Jan 2017 06:07:48 -0800 (PST) In-Reply-To: <20170113114007.15690-1-u@pkh.me> References: <20170113114007.15690-1-u@pkh.me> From: "Ronald S. Bultje" Date: Fri, 13 Jan 2017 09:07:48 -0500 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavc/pthread_frame: protect read state access in setup finish function 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 Cc: =?UTF-8?B?Q2zDqW1lbnQgQsWTc2No?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Hi, On Jan 13, 2017 6:40 AM, "Clément Bœsch" wrote: From: Clément Bœsch --- libavcodec/pthread_frame.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) This has a problem in that we're potentially calling an I/O function that potentially directly enters application space with a lock held. Can the av_log call be moved under a local variable for the condition to after the lock is released? Ronald diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 7ef5e9f6be..cb6d76284e 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -509,11 +509,11 @@ void ff_thread_finish_setup(AVCodecContext *avctx) { if (!(avctx->active_thread_type&FF_THREAD_FRAME)) return; + pthread_mutex_lock(&p->progress_mutex); if(p->state == STATE_SETUP_FINISHED){ av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() calls\n"); } - pthread_mutex_lock(&p->progress_mutex);