From 8503fe3c4fd025e3b6f835a4559a3edfaf55ba08 Mon Sep 17 00:00:00 2001 From: Ryan Lucia Date: Thu, 8 Oct 2026 13:45:24 -0700 Subject: [PATCH] Store the provider lists in vectors to work around a GCC bug GCC miscompiles a namespace-scope std::initializer_list whose elements are a mix of constant-initializable and non-constant ones: the static initializer leaves the constant ones zeroed (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126472). Since #655 added the extensions vector, the Dummy entries of the audio and video provider lists are such elements in C++20, where std::vector's default constructor is constexpr. With an affected GCC (at least 13 through 16.2; fixed for 16.3), every attempt to open audio or video therefore dereferences a null provider name and crashes. A std::vector is initialized correctly. Co-Authored-By: Claude Opus 5.5 --- src/audio_provider_factory.cpp | 8 ++++++-- src/video_provider_manager.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/audio_provider_factory.cpp b/src/audio_provider_factory.cpp index 58c375bb03..bc682474a9 100644 --- a/src/audio_provider_factory.cpp +++ b/src/audio_provider_factory.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include using namespace agi; @@ -42,7 +42,11 @@ struct factory { std::vector extensions; }; -const std::initializer_list providers = { +// This can't be a std::initializer_list: GCC (at least 13 to 16.2) zeroes the +// elements of one that can be constant-initialized (here, the ones with an +// empty extensions list) when others can't be, leaving a null name. +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126472 +const std::vector providers = { {"Dummy", CreateDummyAudioProvider, true, {}}, {"PCM", CreatePCMAudioProvider, true, {".w64", ".wav"}}, #ifdef WITH_FFMS2 diff --git a/src/video_provider_manager.cpp b/src/video_provider_manager.cpp index 97983f50a0..344dcc8a61 100644 --- a/src/video_provider_manager.cpp +++ b/src/video_provider_manager.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include std::unique_ptr CreateDummyVideoProvider(agi::fs::path const&, agi::ycbcr::Header, agi::BackgroundRunner *); std::unique_ptr CreateYUV4MPEGVideoProvider(agi::fs::path const&, agi::ycbcr::Header, agi::BackgroundRunner *); @@ -45,7 +45,11 @@ namespace { std::vector extensions; }; - const std::initializer_list providers = { + // This can't be a std::initializer_list: GCC (at least 13 to 16.2) zeroes the + // elements of one that can be constant-initialized (here, the ones with an + // empty extensions list) when others can't be, leaving a null name. + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126472 + const std::vector providers = { {"Dummy", CreateDummyVideoProvider, true, {}}, {"YUV4MPEG", CreateYUV4MPEGVideoProvider, true, {".y4m", ".yuv"}}, #ifdef WITH_FFMS2