File: soup-init-Use-libdl-instead-of-gmodule-in-soup2_is_loaded.patch

package info (click to toggle)
libsoup3 3.6.5-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,568 kB
  • sloc: ansic: 61,978; python: 202; xml: 97; sh: 84; makefile: 32; javascript: 5
file content (70 lines) | stat: -rw-r--r-- 1,900 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
From: Fabio Manganiello <fabio@manganiello.tech>
Date: Tue, 15 Jul 2025 15:41:47 +0200
Subject: soup-init: Use libdl instead of gmodule in `soup2_is_loaded` check

Calling `g_module_open` in the library constructor can cause deadlocks
when libsoup is used with other libraries that also contend for GLib
mutexes. `dlopen` should be used instead.

Co-authored-by: Nirbheek Chauhan <nirbheek@centricular.com>
Bug: https://gitlab.gnome.org/GNOME/libsoup/-/issues/463
Bug: https://gitlab.gnome.org/GNOME/glib/-/issues/1443
Bug-Debian: https://bugs.debian.org/1109685
Origin: https://gitlab.gnome.org/GNOME/libsoup/-/merge_requests/475
Applied-upstream: 3.7.0, commit:1296cbf983f036f20262c453926dff77e1d6a852
Applied-upstream: 3.6.6, commit:2316e56a5502ac4c41ef4ff56a3266e680aca129
---
 libsoup/soup-init.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/libsoup/soup-init.c b/libsoup/soup-init.c
index 8a33c77..3392e8e 100644
--- a/libsoup/soup-init.c
+++ b/libsoup/soup-init.c
@@ -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;
-
-    if (g_module_symbol (module, "soup_uri_new", &func))
-        result = TRUE;
-
-    g_module_close (module);
-
-    return result;
+	gboolean result = FALSE;
+
+	/* 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