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 660B74CAA3 for ; Tue, 13 Aug 2024 19:19:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4AC8968DA6B; Tue, 13 Aug 2024 22:19:16 +0300 (EEST) Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 770C968D963 for ; Tue, 13 Aug 2024 22:19:09 +0300 (EEST) Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-495d1a6db75so1701246137.1 for ; Tue, 13 Aug 2024 12:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723576747; x=1724181547; 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=/UAoGTrwpm8MXXP38TzAtPfrckM4UEgiF3nfcMVL+EY=; b=Mc6HcxYrCWWH5v6StuTDIXg935069PdyeF5ZR2Oim1MStio2COdzFwJgbDMqlbB8IQ lqu6fs8uuExA9BJgRnwkWMFGvOkt8UkixGmhszkpgz3jdpSTHFcY46eDIQb2d6CA4l4M 6PQHwRR9eQDSoNH6NxIVoDcejGxuq8mNYmUtCv4qP9ePZ1Eu0/z3drQwg/uwlpdQm2ik xg5ZYvWV1kYlSJEcKQ/yldA9O3pUnr/gxdN1Jb69jqwcAcNXPYOWdSh875PffiYLhB+O plcH4yvRac4/bzF9zrQ8xAjdez38SFM9b6sxpZR1CqhjFtyaheGRnYeTpRt2CBINYJ/o bnjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723576747; x=1724181547; 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=/UAoGTrwpm8MXXP38TzAtPfrckM4UEgiF3nfcMVL+EY=; b=fMZZDEOH0IiPu562a63vDl1Kr2Vg1X/18QI2j+CG0QmENIfQZG1ocRefCQomFNRlZn B1jCjYIAD3G8QZ+R1AsQu4oRRQvWKEHaGY1KbnWFD8EI1l1iwHHwpDoyx1zOpeTZP93U E2mr8awZsYKaW6XDUdDdmir0atcYkosC/br9JE9XG8yXhG4BZvQP8VkbGTScAX5mva3p oTHD0FvlGQpo1fMC0zi4KC1YGxjywfMTSYSfygN3DLxWRiD5+KGnoWnYsQS1CRXsqLAf q+Ok40XPL1OC2QBulwJo6XuF7RPatxu8ARML5e9BleBqS2oyqmg2ymKseBPXu8yLmTS8 iKSA== X-Gm-Message-State: AOJu0Yy2VHTk4eJiFEYJfJ2jl6gAOZRrOqeVrL5pPgddRQeUcR7zWus5 oRqbDRBV5IuyzafBkhrHH96Sb64e0FNH+em/pUdWcRstfAag0REyksGL9w== X-Google-Smtp-Source: AGHT+IFxO5mhKk2xOjwrwEFa83RVfZZAMEOXoyJMQ1xibOxvJNZFkucCNbHXJg7+3N0XfOtbb/hUcg== X-Received: by 2002:a05:6102:3048:b0:48f:e802:4b26 with SMTP id ada2fe7eead31-49759944e85mr755478137.18.1723576747036; Tue, 13 Aug 2024 12:19:07 -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 ada2fe7eead31-4970a0999efsm1142355137.25.2024.08.13.12.19.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Aug 2024 12:19:06 -0700 (PDT) Message-ID: Date: Tue, 13 Aug 2024 15:19:05 -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; > } Pushed. _______________________________________________ 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".