debdiff *.dsc | filterdiff -p1 -x'debian/patches/*.patch'

diff -Nru libsoup3-3.6.5/debian/changelog libsoup3-3.6.5/debian/changelog
--- libsoup3-3.6.5/debian/changelog	2025-07-12 09:52:52.000000000 +0100
+++ libsoup3-3.6.5/debian/changelog	2025-07-24 10:40:02.000000000 +0100
@@ -1,3 +1,22 @@
+libsoup3 (3.6.5-3) unstable; urgency=medium
+
+  * Team upload
+  * d/p/soup-init-Use-libdl-instead-of-gmodule-in-soup2_is_loaded.patch:
+    Fix a deadlock in some use patterns with dlopen and GModule.
+    If earlier versions of libsoup were dlopen'd (without using GModule)
+    in thread A, while thread B is holding the GModule lock but not the
+    libdl lock, the process would deadlock: in this scenario, thread A
+    is holding the libdl lock and attempts to take the GModule lock,
+    while thread B is holding the GModule lock and attempts to take the
+    libdl lock.
+    For example, this is known to affect some mopidy plugins, which load
+    libsoup via souphttpsrc.
+    Avoid this by making the check for libsoup2 symbols call dlopen
+    directly, so that there is no lock ordering inconsistency.
+    (Closes: #1109685)
+
+ -- Simon McVittie <smcv@debian.org>  Thu, 24 Jul 2025 10:40:02 +0100
+
 libsoup3 (3.6.5-2) unstable; urgency=medium
 
   * Team upload
diff -Nru libsoup3-3.6.5/debian/patches/series libsoup3-3.6.5/debian/patches/series
--- libsoup3-3.6.5/debian/patches/series	2025-07-12 09:52:52.000000000 +0100
+++ libsoup3-3.6.5/debian/patches/series	2025-07-24 10:40:02.000000000 +0100
@@ -1,3 +1,4 @@
+soup-init-Use-libdl-instead-of-gmodule-in-soup2_is_loaded.patch
 skip-tls_interaction-test.patch
 Record-Apache-error-log-for-unit-tests-and-show-it-during.patch
 test-utils-Add-more-debug-for-starting-stopping-Apache.patch
diff -Nru libsoup3-3.6.5/libsoup/soup-init.c libsoup3-3.6.5/libsoup/soup-init.c
--- libsoup3-3.6.5/libsoup/soup-init.c	2025-03-21 18:30:16.000000000 +0000
+++ libsoup3-3.6.5/libsoup/soup-init.c	2025-07-24 11:25:24.000000000 +0100
@@ -10,7 +10,6 @@
 #endif
 
 #include <glib/gi18n-lib.h>
-#include <gmodule.h>
 #include "gconstructor.h"
 
 #ifdef G_OS_WIN32
@@ -18,21 +17,28 @@
 #include <windows.h>
 
 HMODULE soup_dll;
+#else
+#include <dlfcn.h>
 #endif
 
 static gboolean
 soup2_is_loaded (void)
 {
-    GModule *module = g_module_open (NULL, 0);
-    gpointer func;
-    gboolean result = FALSE;
+	gboolean result = FALSE;
 
-    if (g_module_symbol (module, "soup_uri_new", &func))
-        result = TRUE;
-
-    g_module_close (module);
-
-    return result;
+	/* Skip on PE/COFF, as it doesn't have a flat symbol namespace */
+#ifndef G_OS_WIN32
+	gpointer handle;
+	gpointer func;
+
+	handle = dlopen (NULL, RTLD_LAZY | RTLD_GLOBAL);
+	if (handle != NULL) {
+		func = dlsym (handle, "soup_uri_new");
+		result = (func != NULL);
+		dlclose (handle);
+	}
+#endif
+	return result;
 }
 
 static void
