From d3a996e64d8f7dc7d90333bafadb6979848bd8ab Mon Sep 17 00:00:00 2001 From: Michael Catanzaro Date: Thu, 10 Oct 2024 09:56:30 -0500 Subject: [PATCH] Add patch to keep GSocketMonitor callback alive Resolves: RHEL-59181 --- socket-monitor.patch | 59 ++++++++++++++++++++++++++++++++++++++++++++ webkit2gtk3.spec | 9 ++++++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 socket-monitor.patch diff --git a/socket-monitor.patch b/socket-monitor.patch new file mode 100644 index 0000000..5687f68 --- /dev/null +++ b/socket-monitor.patch @@ -0,0 +1,59 @@ +diff --git a/Source/WTF/wtf/glib/GSocketMonitor.cpp b/Source/WTF/wtf/glib/GSocketMonitor.cpp +index c88ea9f91ca49..f3e31efb50530 100644 +--- a/Source/WTF/wtf/glib/GSocketMonitor.cpp ++++ b/Source/WTF/wtf/glib/GSocketMonitor.cpp +@@ -33,6 +33,7 @@ namespace WTF { + + GSocketMonitor::~GSocketMonitor() + { ++ RELEASE_ASSERT(!m_isExecutingCallback); + stop(); + } + +@@ -40,7 +41,17 @@ gboolean GSocketMonitor::socketSourceCallback(GSocket*, GIOCondition condition, + { + if (g_cancellable_is_cancelled(monitor->m_cancellable.get())) + return G_SOURCE_REMOVE; +- return monitor->m_callback(condition); ++ ++ monitor->m_isExecutingCallback = true; ++ gboolean result = monitor->m_callback(condition); ++ monitor->m_isExecutingCallback = false; ++ ++ if (monitor->m_shouldDestroyCallback) { ++ monitor->m_callback = nullptr; ++ monitor->m_shouldDestroyCallback = false; ++ } ++ ++ return result; + } + + void GSocketMonitor::start(GSocket* socket, GIOCondition condition, RunLoop& runLoop, Function&& callback) +@@ -65,7 +76,13 @@ void GSocketMonitor::stop() + m_cancellable = nullptr; + g_source_destroy(m_source.get()); + m_source = nullptr; +- m_callback = nullptr; ++ ++ // It's normal to stop the socket monitor from inside its callback. ++ // Don't destroy the callback while it's still executing. ++ if (m_isExecutingCallback) ++ m_shouldDestroyCallback = true; ++ else ++ m_callback = nullptr; + } + + } // namespace WTF +diff --git a/Source/WTF/wtf/glib/GSocketMonitor.h b/Source/WTF/wtf/glib/GSocketMonitor.h +index 7ec383a6e37c7..9393c546b5938 100644 +--- a/Source/WTF/wtf/glib/GSocketMonitor.h ++++ b/Source/WTF/wtf/glib/GSocketMonitor.h +@@ -51,6 +51,8 @@ class GSocketMonitor { + GRefPtr m_source; + GRefPtr m_cancellable; + Function m_callback; ++ bool m_isExecutingCallback { false }; ++ bool m_shouldDestroyCallback { false }; + }; + + } // namespace WTF diff --git a/webkit2gtk3.spec b/webkit2gtk3.spec index b2c06ad..349bc62 100644 --- a/webkit2gtk3.spec +++ b/webkit2gtk3.spec @@ -21,7 +21,7 @@ Name: webkit2gtk3 Version: 2.46.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: GTK Web content engine library License: LGPLv2 @@ -41,6 +41,9 @@ Patch: webkitgtk-skia-musttail.patch # Resolves: https://github.com/simd-everywhere/simde/issues/1211 Patch: simde.patch +# Containing changes from: https://github.com/WebKit/WebKit/pull/34133 +Patch: socket-monitor.patch + BuildRequires: bison BuildRequires: bubblewrap BuildRequires: cmake @@ -313,6 +316,10 @@ export NINJA_STATUS="[%f/%t][%e] " %{_datadir}/gir-1.0/JavaScriptCore-4.0.gir %changelog +* Thu Oct 10 2024 Michael Catanzaro - 2.46.1-2 +- Add patch to keep GSocketMonitor callback alive + Resolves: RHEL-59181 + * Mon Sep 30 2024 Michael Catanzaro - 2.46.1-1 - Update to 2.46.1 Resolves: RHEL-59181