From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0D4614B553 for ; Mon, 8 Jul 2024 14:07:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 09CF068DC50; Mon, 8 Jul 2024 17:07:44 +0300 (EEST) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6DE1068DC12 for ; Mon, 8 Jul 2024 17:07:37 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 3D91427FFCE89 for ; Mon, 8 Jul 2024 16:07:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1720447656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kdybtsJjfI/zEkbel6E8qvjyZTC0R+Qf+RFtm+Orz1U=; b=ACjSKMHkteKobiM5sgz9Jq66qT5dQz3LU+IcdOXIlKwnnMQxW+7ryUlgRzc3iWS4JJOspa Q6gK5r/yKIK/V3AR7ofIajh8qMHHnlhLtrjjAm+CtkxrXdscsbI8a/UyjPND7WxSDcagwn K5vYObKeDvAAR3vQ0TEqRIBoUhBIK/Q54kkLKqN50SKBC+F9yr7tfvei1sLGE/58EhkTI7 nMEtBtO4p06s6ExMfNIdN4X7I7zORwSKR9bsc8CKr+itvabNXPtSvvULFLnhGiJ7RiG7Bn hDFrJrUs6ntczM0KAYqg2/lDvaV+IRwspFwFFytCpyPsG9DDQIAPCHDrlchWrA== Message-ID: <32130928-d5a6-4d50-be0a-4d6d4fa417cb@rothenpieler.org> Date: Mon, 8 Jul 2024 16:07:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: Content-Language: en-US From: Timo Rothenpieler In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 2/2] avutil/executor: Fix stack overflow due to recursive call X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 08.07.2024 09:43, Zhao Zhili wrote: > From: Zhao Zhili > > av_executor_execute run the task directly when thread is disabled. > The task can schedule a new task by call av_executor_execute. This > forms an implicit recursive call. This patch removed the recursive > call. > --- > libavutil/executor.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/libavutil/executor.c b/libavutil/executor.c > index 89058fab2f..c145c51be9 100644 > --- a/libavutil/executor.c > +++ b/libavutil/executor.c > @@ -58,6 +58,7 @@ struct AVExecutor { > int die; > > AVTask *tasks; > + int stack_depth; > }; > > static AVTask* remove_task(AVTask **prev, AVTask *t) > @@ -207,8 +208,12 @@ void av_executor_execute(AVExecutor *e, AVTask *t) > } > > if (!e->thread_count || !HAVE_THREADS) { > + if (e->stack_depth > 0) > + return; > + e->stack_depth++; > // We are running in a single-threaded environment, so we must handle all tasks ourselves > while (run_one_task(e, e->local_contexts)) > /* nothing */; > + e->stack_depth--; Won't this put the above line into the "nothing" while-loop? Is that intended? If so, the indentation should be adjusted accordingly. If not, the while-loop should gain empty {}. > } > } _______________________________________________ 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".