File: server-mem-limit-test-Limit-memory-usage-only-when-not-bu.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 (61 lines) | stat: -rw-r--r-- 2,321 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
From: Milan Crha <mcrha@redhat.com>
Date: Tue, 13 May 2025 14:20:46 +0200
Subject: server-mem-limit-test: Limit memory usage only when not built witha
 sanitizer

A build with -Db_sanitize=address crashes with failed mmap(), which is done
inside libasan. The test requires 20.0TB of virtual memory when running with
the sanitizer, which is beyond unsigned integer limits and may not trigger
the bug anyway.

Origin: upstream, 3.7.0, commit:eeace39ec686094ff6a05a43e5fce06e9c37f376
Bug: https://gitlab.gnome.org/GNOME/libsoup/-/issues/428
Bug-Debian: https://bugs.debian.org/1103264
---
 meson.build                   |  4 ++++
 tests/server-mem-limit-test.c | 13 +++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/meson.build b/meson.build
index d4110da..74323ea 100644
--- a/meson.build
+++ b/meson.build
@@ -357,6 +357,10 @@ configinc = include_directories('.')
 
 prefix = get_option('prefix')
 
+if get_option('b_sanitize') != 'none'
+  cdata.set_quoted('B_SANITIZE_OPTION', get_option('b_sanitize'))
+endif
+
 cdata.set_quoted('PACKAGE_VERSION', soup_version)
 cdata.set_quoted('LOCALEDIR', join_paths(prefix, get_option('localedir')))
 cdata.set_quoted('GETTEXT_PACKAGE', libsoup_api_name)
diff --git a/tests/server-mem-limit-test.c b/tests/server-mem-limit-test.c
index 98f1c40..65dc875 100644
--- a/tests/server-mem-limit-test.c
+++ b/tests/server-mem-limit-test.c
@@ -126,14 +126,19 @@ main (int argc, char **argv)
 {
 	int ret;
 
-	test_init (argc, argv, NULL);
-
-	#ifndef G_OS_WIN32
-	struct rlimit new_rlimit = { 1024 * 1024 * 64, 1024 * 1024 * 64 };
+	/* a build with an address sanitizer may crash on mmap() with the limit,
+	   thus skip the limit set in such case, even it may not necessarily
+	   trigger the bug if it regresses */
+	#if !defined(G_OS_WIN32) && !defined(B_SANITIZE_OPTION)
+	struct rlimit new_rlimit = { 1024UL * 1024UL * 1024UL * 2UL, 1024UL * 1024UL * 1024UL * 2UL };
 	/* limit memory usage, to trigger too large memory allocation abort */
 	g_assert_cmpint (setrlimit (RLIMIT_DATA, &new_rlimit), ==, 0);
+	#else
+	g_message ("server-mem-limit-test: Running without memory limit");
 	#endif
 
+	test_init (argc, argv, NULL);
+
 	g_test_add ("/server-mem/range-overlaps", ServerData, NULL,
 		    server_setup, do_ranges_overlaps_test, server_teardown);