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 BB3FB474AA for ; Mon, 8 Jul 2024 07:43:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EA35F68DC2A; Mon, 8 Jul 2024 10:43:20 +0300 (EEST) Received: from out203-205-221-210.mail.qq.com (out203-205-221-210.mail.qq.com [203.205.221.210]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BFD3F68D8DF for ; Mon, 8 Jul 2024 10:43:13 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1720424585; bh=Vs0xeD7P/zSm0ttANOF/JldT9tHC63gNc/RKAyYCxgw=; h=From:To:Cc:Subject:Date; b=YG/xz6yQrq1QqiNfD4k2P3dqX6wNsWy8eipjjrrpYbpDGfMkWwRax5Bh0eN22CUDq 1Y4YdDHIwpCLnmbY36CrL2V8oNQ0dBXKm9duv6tiMmcbyxx3A7hgEOKVxgDqR+mYBj QPpJlv2HbHFJnWqE/yy641Hr6hPiZEYv9fwAb+UA= Received: from ZHILIZHAO-MB1.tencent.com ([119.147.10.207]) by newxmesmtplogicsvrsza15-1.qq.com (NewEsmtp) with SMTP id AC48E04C; Mon, 08 Jul 2024 15:43:04 +0800 X-QQ-mid: xmsmtpt1720424584tpneqfk43 Message-ID: X-QQ-XMAILINFO: MvM61XSVXCtDKiDE+fao4/U/dREPmj9ndONnfOS9Uf8WHqoLVmEU/fZg7YmScl tKS5ZqKOJaoyamANDXQiRga1ebZyZGaHb+J7PXb2JYpJsHQnY/nALFtLMnDtsC89uW6UP5qhyyMF h+6oc+ndegWWPlwljBp7GeUOQ+UJIywbBcExSHvv5z3ZM0yrrRyKXpvYIjz6MNmU4mX6RFCQDRo2 oAZTuyUBRvsZyVqKVQJ8xws68xrUQka9+jcjQyKYKYTn5lTwpJmryFaR3ier9rxmvQjPcdkOtQpG DmSZRuOHNFyivU+m4Wkij4rJF/cicjH3/Kr6thKdGJgRSqC/pCVVxxVwDSPjkfNS4/I/N3sF2OKp y3/MAC0yvTvPb+/muGZtxtfTZw7YF1Vn0fd3pJiqdLdyJjRIgtliAbaboR5EUoeZXoxy8szO282u bPYLKZuui0pxP41OmwWb2NpKMxCaTTywAtwhU+mYqFoP/w3HnwLpKculA03c2yVGDIP7Tip75Unv eqPFut5ldHI6kcqVxEFU+xGLPeJKArpGOObaDVl2deo7fXsp+9zRflDgUdcbD/5vJqLgPphmhClK kl/v4rOhrVC3Fd56LqjbWtt/CJ54JZfI1WtwaehZv1UDX0WxJj3KgR35zE5iSvHqLKHaj3RxnOWX Lzv6vIB8jkUIleUENFDyJg3I+HajZi5vQXDKKYEf6iI+RNacxSb8RRGCGFo01CT8FrrDvtOzJcAt KQiwwYp+6pCVg3ytORCz4naNMN/jD/xx8Z7fVzaiwltpZCHjs9xKECVWdPycJF2zuYZTQLF2DJlu 2wPFbxBmpdcOqGQWM1RihabnzHajE9FcpjWGyWSilMOH0fq+RMAskmmQv4nMUwSjs7ys+ox5TUNo U3KGvUNNnWShMzjKE0rNx4vrPVRTwe7NVXkfNGVuchwjLM2fudZscC+opRUGwclUtf76GbdCes1L erA5Th5ey8KkyA1kMxxYl8YQHmX9C5eoZJK6fl7RdFO+H3f6Ry/CGBvuVq+LYbKrBJ8sjNIiWWzz /sNqaNhnkiZsuAw1fj+OltJEje5YCIxweT3VTB1Q== X-QQ-XMRINFO: M/715EihBoGSf6IYSX1iLFg= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jul 2024 15:43:03 +0800 X-OQ-MSGID: <20240708074303.14785-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [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 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. --- 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--; } } -- 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".