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 A8A0F4B497 for ; Sun, 7 Jul 2024 03:25:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6649568DAAC; Sun, 7 Jul 2024 06:25:29 +0300 (EEST) 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-Google-Smtp-Source: AGHT+IExbOwmujsT52vucsZB+4NRcICDhMr+CucuPgksgmw77jS254FlKeLePfwgzCnS0V9uW3BiXg== 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 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 --- 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) { -- 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".