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 64CAE4BFAB for ; Fri, 19 Jul 2024 16:56:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EB61068D97E; Fri, 19 Jul 2024 19:56:40 +0300 (EEST) Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3A34D68D7E8 for ; Fri, 19 Jul 2024 19:56:34 +0300 (EEST) Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-4f2f31a9410so722867e0c.3 for ; Fri, 19 Jul 2024 09:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721408192; x=1722012992; 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=Kr/bfQRt1fbFaEK/fvLck62sUi24aYJAjNFf+xE380E=; b=YaxmqApXDIA4V6UYiWMnkr79kSw5bY/m58TiJG7UycQBrr8HTgGvB0/6T09Y76Yl1Q MCRaTE35AsFRNKQ81jSxQiaRk4uYX+KANJxrSLOOh8h4RGIVm+cN1JD/9HDDNsPwQzur adAUkwqYPNAxd+ryiQfbitZieQhb1sKRIXmBbUwVipw0psz6b8OSIQXpoFkkQ1Q2L8Qf B3PSBYyvBMbWsOfZz2ayd5owl8ZX+bwLPIZ7BKWc+VEtPz0MeF4DPmUOxWA52EAWelfs 8+hXi6F+19dHgo9TqrIDeLj3TsSqpJcfT3iR7FXOgDoqMe+X2QFyhU3+Jx1Bb+TTsrdo J3ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721408192; x=1722012992; 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=Kr/bfQRt1fbFaEK/fvLck62sUi24aYJAjNFf+xE380E=; b=Iixu98QBnCygG9ydYdQl1gaRpuLfDgfTlMZwH2Vl40kDhizfDABgtcbeAhnGMdKisp PUKXfAluNqHZUXGwTWuDJDGIKq+DjMfUJjoa32mg7YQWZZYAhVpRg2r8tWfGS1397lcq MzCylRKGlrP6hgzMVOqFn5Bc/Jtu/PqEUnPSuPJ0rY5TuqrDDFsgGPmh87ma49QnLPN0 WHPOqMzIV08Vq1PrX+3gl7ZpTvcuT8NZgXUP1TOYBFw0wdjNyTpnnM/8LP+ILGHovvcY yiT47NQeOBv4UNUiieHuf0GzTNnUipnJf44W7JH25HI1iYU5QdPhrRrZ8Ar/WJvdK+Mg 4mhw== X-Gm-Message-State: AOJu0Yw6EF5iKHNEwaCDzRiKIKyG7Vz4GYHe2g/tGX8DfXXmtI+C/rPW bSwViYjRyem1SOlS7aNu+RYPlU/a0eYtJ4nyLI3gAXHpFB8me1rertO2EA== X-Google-Smtp-Source: AGHT+IGB+4lh+bH28IqcMuLpLALl7Vky4/I3THhFx/+Kva4pdAu6l6TAdlp3HLOP/Dsy14mFlt/vUg== X-Received: by 2002:a05:6122:905:b0:4ef:58d4:70f5 with SMTP id 71dfb90a1353d-4f4df64cff8mr10700285e0c.2.1721408191656; Fri, 19 Jul 2024 09:56:31 -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-4f4f9e868easm176960e0c.30.2024.07.19.09.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 09:56:31 -0700 (PDT) From: Stephen Hutchinson To: ffmpeg-devel@ffmpeg.org Date: Fri, 19 Jul 2024 12:56:26 -0400 Message-ID: <20240719165627.5490-1-qyot27@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2 v2] 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 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: 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 --- Changes compared to v1: * Added missing dlclose invocation to read_close libavformat/avisynth.c | 46 +----------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 625bdf7e3a..26747671c0 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) { @@ -1134,6 +1089,7 @@ static av_cold int avisynth_read_close(AVFormatContext *s) return AVERROR_UNKNOWN; avisynth_context_destroy(s->priv_data); + dlclose(avs_library.library); ff_mutex_unlock(&avisynth_mutex); return 0; } -- 2.43.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".