From patchwork Sun Jul 7 03:25:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hutchinson X-Patchwork-Id: 50379 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:cc64:0:b0:482:c625:d099 with SMTP id k4csp5154336vqv; Sat, 6 Jul 2024 22:54:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUV/mqB/tf9nVdX8S4qxkn5jtCepT1x8wXunlKVwQMZlzJP3c+4XzuMy05Ww8a3N74zqsEBXjHXMdY0tYGw9wL3hWd8G9avmU2eCw== X-Google-Smtp-Source: AGHT+IHmn/USq4Uvcwi5Rxngm6rzNEBIEudP87QeHUqg/p86T6/yCrhDx+WVeH4Gbxv2Ts5TirU1 X-Received: by 2002:a05:6512:4884:b0:52c:f55d:44a3 with SMTP id 2adb3069b0e04-52ea0622628mr7350278e87.19.1720331647881; Sat, 06 Jul 2024 22:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720331647; cv=none; d=google.com; s=arc-20160816; b=h6m2hiUH6bHO45sAaPduo72bQWCrVRG2/zfRbE4zQ6HCKuSbHvTQAwNmdMShPm1yaa XPLWV3jxH3tdGJO13gr8soH4ek0rzDDTkqs23eWUGj38Po2bHMHA5mGookQ2vpBWfu6M pgqqH0EtJdfAN4+GoMhRGVilAfljsXcGb0ngHhgtCB6qmuFlAenrxQ3LX8Yhgg7YVFlq ZFfCWD1BSxhVLXbTEgMMdkUyUlG4XHHaBXAksPBBKG4sXiyDZUOaUU2lVFOIkjqWo0MG xTPAq6ek16uZnD5CC23umY8zKLcjno5C7jWkLxnhuxO2KQR+mUZ+vSdGSu99v8rBCEUm eiyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=1VHrVNADwl5/4Kiwae16U1lTP3TozwgA0PbR8jSTZ/Q=; fh=dF+SszRLFyubUCP/LDvIY2NwiNB1Gp0Txz6w70WKHpo=; b=i0/hYAbQcjXCCgYubF4ElJDW+j/8IU5YoLaN2169gasWryqLbDpuHXkZYblhHqE0bg Cqo15zK8zvsZAVX1sC3HlYShmgvVl1OQiL63If/+4Xg1w0gSAPyG9TlQWwaJ61OLccTD LMnGDbTUhRLHkS3SkvZjEeqWDMB2qT9b0Z5kQk+JsC8p3dqUY2SO970sXfEhQavIJwYi l4+y0lYsBv2Hw1WEYaYWt9VRImE0bkHjQoP1ckQdi28CS75o1YGyL3BEIsDNWNSBFbh1 5aTLlVKIM5utC5xRYQsNkfEYMw+TjFN71x0Cg6WlbbP0Zunct6GRmtZYRF0MQmOD21Jr MQfQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=ar2BSzwO; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-52e7ab25989si6147873e87.267.2024.07.06.22.54.07; Sat, 06 Jul 2024 22:54:07 -0700 (PDT) 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 header.s=20230601 header.b=ar2BSzwO; 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=QUARANTINE 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 F10E368D804; Sun, 7 Jul 2024 06:25:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E37568D9BF for ; Sun, 7 Jul 2024 06:25:23 +0300 (EEST) Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-4f30f3be999so300783e0c.3 for ; Sat, 06 Jul 2024 20:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720322721; x=1720927521; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dcTlbuqv1H5LJUj4ohhSKv0CWkcLdNI4FO+jOTZqAGc=; b=ar2BSzwO1IatVmjowGuJO7gTOTTt27Q5xpJPG/6ctZbbhWAtfrtpXbOC/sWn4eDQye mks2cCPb9wlbhjhtDOJXC3wvcKcysZP7hV7405tqVYmGa4M9ghkV6mji/7ou6oO8PcpU 4E8cINcjoQhsTdwRq+WhUHYNCGyFoqIzTq0a2UbxlLh3QqCZ5hG5x9kbJhegURuiCXcW FZgWJrpeMAv4q28ynIXudv96/F2g1oKxq1GSLAtlKEWeZzZL5zSpHV2mOiQUSHfTc2HS Q9VmaFm+/bZWehtGx3G3ct9Bk5/TPqcoX54KOwFye6OWJBD418yMKs/w/IV9wZhxDVAE 6Xfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720322721; x=1720927521; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dcTlbuqv1H5LJUj4ohhSKv0CWkcLdNI4FO+jOTZqAGc=; b=dlZEnvg7NAlmXBbbHtXOeI/D1/beMkNp/6YbzY7UzomZLGS+6vy9dzxbhLtQ/XqjcJ qtY9t8fSjp+d1ITM80tkIZy5ROfPi8UTCaR1Mr40fibijLVE431JmavxYyQkzaAZ4yPv g/aQYPTYaip+y5MYIqD4RQOZeW9xYI0WqmLcDZlf6eHWqrNGpSVL+abo/lj0YkBvuZLL Dhzn0Nuw70IFmgGSFPOIk7ZJNvnHr+KF77DpugkNrNY+eKMAouZ00laKQW9ENZE5YGTz bRMHvYlMPxK+rUIM8K8AypVtbHVjjvRgiF3jXJccyTXEY1H/p5+0smTx85KkH1mfLnTd skVA== X-Gm-Message-State: AOJu0Yyn4o3DzfFwAnCa0cDzwwIl/RRx9jNpJFIzDooLgGrWermfJ5zI a2jYbnE6hpqsDVFBS7PWDMTrQIbZ4SoUtiBhLdzII361nQoVL0bayGFrKg== X-Received: by 2002:a05:6122:6607:b0:4e4:ed90:27e6 with SMTP id 71dfb90a1353d-4f2f3e869abmr9679297e0c.5.1720322720963; Sat, 06 Jul 2024 20:25:20 -0700 (PDT) Received: from cappuccino.. (syn-173-170-140-230.res.spectrum.com. [173.170.140.230]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-4f2f5150c4dsm795081e0c.14.2024.07.06.20.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jul 2024 20:25:20 -0700 (PDT) From: Stephen Hutchinson To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Jul 2024 23:25:11 -0400 Message-ID: <20240707032511.2714-1-qyot27@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/avisynth: remove atexit() handler 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: Stephen Hutchinson Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: iTXgLyMa4fY0 The atexit() handler in the avisynth demuxer was added because there was a conflict in AvxSynth that arose due to their use of C++ global objects, particularly in relation to having added a logging function relying on log4cpp. This conflict was responsible for causing a segfault on exit. It did not affect Windows with the (at the time) upstream AviSynth 2.5 and 2.6, nor does it affect AviSynth+. Unfortunately, none of this was actually shielded by ifdefs indicating the fact it was only needed for AvxSynth, so four years ago when AviSynth+ replaced AvxSynth as the handler for AviSynth scripts on Unix-like OSes, the fact that the atexit handler was no longer necessary was overlooked. Signed-off-by: Stephen Hutchinson --- libavformat/avisynth.c | 45 ------------------------------------------ 1 file changed, 45 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 625bdf7e3a..5d1ecc0bf6 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -115,9 +115,6 @@ typedef struct AviSynthContext { int error; uint32_t flags; - - /* Linked list pointers. */ - struct AviSynthContext *next; } AviSynthContext; static const int avs_planes_packed[1] = { 0 }; @@ -133,15 +130,7 @@ static const int avs_planes_rgba[4] = { AVS_PLANAR_G, AVS_PLANAR_B, static AVMutex avisynth_mutex = AV_MUTEX_INITIALIZER; -/* A conflict between C++ global objects, atexit, and dynamic loading requires - * us to register our own atexit handler to prevent double freeing. */ static AviSynthLibrary avs_library; -static int avs_atexit_called = 0; - -/* Linked list of AviSynthContexts. An atexit handler destroys this list. */ -static AviSynthContext *avs_ctx_list = NULL; - -static av_cold void avisynth_atexit_handler(void); static av_cold int avisynth_load_library(void) { @@ -185,7 +174,6 @@ static av_cold int avisynth_load_library(void) LOAD_AVS_FUNC(avs_get_env_property, 1); #undef LOAD_AVS_FUNC - atexit(avisynth_atexit_handler); return 0; fail: @@ -214,30 +202,11 @@ static av_cold int avisynth_context_create(AVFormatContext *s) } } - if (!avs_ctx_list) { - avs_ctx_list = avs; - } else { - avs->next = avs_ctx_list; - avs_ctx_list = avs; - } - return 0; } static av_cold void avisynth_context_destroy(AviSynthContext *avs) { - if (avs_atexit_called) - return; - - if (avs == avs_ctx_list) { - avs_ctx_list = avs->next; - } else { - AviSynthContext *prev = avs_ctx_list; - while (prev->next != avs) - prev = prev->next; - prev->next = avs->next; - } - if (avs->clip) { avs_library.avs_release_clip(avs->clip); avs->clip = NULL; @@ -248,20 +217,6 @@ static av_cold void avisynth_context_destroy(AviSynthContext *avs) } } -static av_cold void avisynth_atexit_handler(void) -{ - AviSynthContext *avs = avs_ctx_list; - - while (avs) { - AviSynthContext *next = avs->next; - avisynth_context_destroy(avs); - avs = next; - } - dlclose(avs_library.library); - - avs_atexit_called = 1; -} - /* Create AVStream from audio and video data. */ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) {