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 9CCCD45CFC for ; Sun, 28 Jul 2024 05:37:43 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5A01868D200; Sun, 28 Jul 2024 08:37:41 +0300 (EEST) Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0FE3F68CDFE for ; Sun, 28 Jul 2024 08:37:34 +0300 (EEST) Received: by mail-ua1-f49.google.com with SMTP id a1e0cc1a2514c-81f91171316so1009858241.0 for ; Sat, 27 Jul 2024 22:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722145052; x=1722749852; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=FJmti/bEReJg3hWmk0DbUDOrIuZxJMK2HOjGyrMloZ4=; b=hl1IBqoVy2sXkrkmLAb3j4HMqp/LVeFWbQoJMBcmQYhwBwqk4eZMYkryt6MZ0EIiHl 3qFuY6fzN5PZYXu0arDkEJcVLCawcUBU0UXqH1DE4s5onqkgg99OCXx6N9rGKFnSm1mT 8PewIhozw9EVgfQjbh0NqjE+WE5LLbDU9J1XEcF8tG/O0xxXi9w2gx8Xr77tVuD7YNBe pvw0PPWmjGOkRvGC9v5nGDoJcxf1JLvO6u6KsQdXHJkRtdUxuymiXzlQo91EGMdRmELd Ja2Qoh/Ao1CicqN9q+aSo9jqAKFnFYYalCn+/5jjB+USx870SZDp0W+qCjlO0W/ka5us hrvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722145052; x=1722749852; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FJmti/bEReJg3hWmk0DbUDOrIuZxJMK2HOjGyrMloZ4=; b=Ee3WNEBDDRp/ng2xrrJsS0gJMT3iZEiNNd1UCm0MAk6UgILkw3NBP4P96XOy6h9Tg8 LGQDniKIR8musyeKpT7dlJndfX3FGGw0BswblKpGdpXoFlXRohoqGgLOwUV8U4GrnGJH 4HyJCkWSyBYQMTqTM33EZ2p5iF286DofvgF1vUJahuFPKyantvJXyBiKu1EiNJqpDsjv P23GDwmROqA4F3TxJl78tGHwyNkqefnnQW4qK7rmLZOCio2+o46bVOT82gVbB7ITRnfk N4Mu2iMN9hyKb6jj4c6my/UMqUUBIAgsDruZ2uAleF/SWwKnREdBkKNL2H5IDrH8MtM8 gd6w== X-Gm-Message-State: AOJu0Yyoc+Fa1+kH/DsafHjppGwqLgmgWZza3zAbaIDD3iZM+d6V53VR 9mLo9YWnY12iOlWlHLNChun2tEjy20DL9xX7GXVS8s5ugp1Uwl2ug531Bw== X-Google-Smtp-Source: AGHT+IHFLvGj1ZqOSbhR0zNyPT/+erK752DmifKHgrGO3qRTFepF2YRJPamxxW9UqqU1r9lsUvMPDw== X-Received: by 2002:a05:6102:4405:b0:48f:12e5:bd8a with SMTP id ada2fe7eead31-493fb0c6506mr2020793137.12.1722145052373; Sat, 27 Jul 2024 22:37:32 -0700 (PDT) Received: from [192.168.1.20] (syn-173-170-140-230.res.spectrum.com. [173.170.140.230]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-831afeb0fc3sm921358241.3.2024.07.27.22.37.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Jul 2024 22:37:31 -0700 (PDT) Message-ID: Date: Sun, 28 Jul 2024 01:37:31 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: FFmpeg development discussions and patches References: <20240719165627.5490-1-qyot27@gmail.com> Content-Language: en-US From: Stephen Hutchinson In-Reply-To: <20240719165627.5490-1-qyot27@gmail.com> Subject: Re: [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 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 7/19/24 12:56 PM, Stephen Hutchinson wrote: > 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; > } Since there's not been any more feedback, I'll push both of these refined patches in a day or two. _______________________________________________ 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".