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 900F34B546 for ; Mon, 8 Jul 2024 12:14:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 20EE668DC30; Mon, 8 Jul 2024 15:13:58 +0300 (EEST) Received: from out203-205-251-53.mail.qq.com (out203-205-251-53.mail.qq.com [203.205.251.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB52F68DAA8 for ; Mon, 8 Jul 2024 15:13:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1720440820; bh=D4f4rFT3K9yhUpIoLeAJ4asS65cz3zOlmV5tktQi41s=; h=From:To:Cc:Subject:Date; b=izhfp1xCeFQO7rWYb+AcTMRCtYgGo9yFu4+LLhQ9fTSjSbQc8kJPY49uuRuC6BMQa 9A6pPrmn+sOGkW6H0244mn6JFqWgAdxiOE9lh4b/pqaJTDzjsa73fPHQtr/azUpKj9 ZdDnBt3q2chZBva9eW15yVXG23TGu2p72AqR28fI= Received: from ZHILIZHAO-MB1.tencent.com ([113.108.77.64]) by newxmesmtplogicsvrszb16-1.qq.com (NewEsmtp) with SMTP id 366B1A3A; Mon, 08 Jul 2024 20:13:38 +0800 X-QQ-mid: xmsmtpt1720440818tz0ya79b3 Message-ID: X-QQ-XMAILINFO: Mm/8i8/T4ynetaGveWD+gPWZE5TWATmFs1nvvqHTZb/9jNcY+JSWQQ4u4xnchm 3UfqQRuPrGPoX7/2/e5yjyKkey7V2HYhpnfTuEWK7Wzvycf9JfekyJ+IYTzlWQAUmjsDv1rmESzr XXWOfTbyDjfEe00sLi0fRc06tCWuO+UO/bMiGqLyi+yCMgi4w0mn4oTpfkJdHVdWvhorCYA0Y3ax fWMbTjBFWbocgyF9MNNxSJ4c631cKjioBBUJaRNDcDKgT5HG/ZnA0Bmbw+zBhY9MTNt2FvcKzFm2 GgjuSQSUNU7uIHS9xGFDgAMjsTlMgR7S31cK4LR2kR9BB3QgbXEVuHhf19snG9f7grv2Ga/SGnIi j0XlOJv1UMe8JCXiNzV4z6Tx0IuWuZ3S8OdSIwCRCy+pBAOkgcPx0FLTA6e6ZoI1I8XcoPB0aPYi oFqhN8wnILXS6xCuaYovPaVMpzj3mHYxh8h/HEYWn176yWRInvPrGELZhS88BMpRSBQWv69dP4QI 02Q0ZiHQ8YvgU7qNtBYWvsoXEZcufLiKVj5cedCBdjp0SeV6pD0k3ApyuwbEE2RQlN2pLrPp2nZq S2I+Zbt+x6WRtHkuMVJZwSeIp/RccfRoG7pApEg7YLIJIe1kc/VXXeEGwtYQvy5wFHSQGDL5VXUl QHwb8O0QbmRhjLTKgFmNl7UWI1FnybtP/zzytdZQ1shpNKKaGSmGrdBFkSWJFZ58DNnSCxw5OOpC 2JTg/drOifKCsbIQa7hSEeXi/QYV1E4/KvIsD0LvbxxcaX87hD7/MHJ4dipmdKZJHL5xZwuILiji rxxgHpmBRbJeINkXhZsE/YL3lxiAtIO2AioY4RoHgzmXhMcC7BtgB9a4h/BnwJFK92BmqsYvdbDB y3gDk6ofdAblU/OjqS7SPlZ9bPK+reaEfGeUAJNTWqc5k15S+qsqhsYplWRDuy7zX0dgHsl8AzBn TOmN5kqt7Xv9VgVf60/itaiGpRkpU6UeM4KqSqGEQ8Qq7hNLevpOYNwchpa+fA X-QQ-XMRINFO: OWPUhxQsoeAVDbp3OJHYyFg= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jul 2024 20:13:37 +0800 X-OQ-MSGID: <20240708121337.84256-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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 Cc: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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. --- v2: use bool type libavutil/executor.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavutil/executor.c b/libavutil/executor.c index 89058fab2f..bfce2ac444 100644 --- a/libavutil/executor.c +++ b/libavutil/executor.c @@ -20,6 +20,8 @@ #include "config.h" +#include + #include "mem.h" #include "thread.h" @@ -49,6 +51,7 @@ typedef struct ThreadInfo { struct AVExecutor { AVTaskCallbacks cb; int thread_count; + bool recursive; ThreadInfo *threads; uint8_t *local_contexts; @@ -207,8 +210,12 @@ void av_executor_execute(AVExecutor *e, AVTask *t) } if (!e->thread_count || !HAVE_THREADS) { + if (e->recursive) + return; + e->recursive = true; // 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->recursive = false; } } -- 2.42.0 _______________________________________________ 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".