public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fix for __sanitizer_struct_mallinfo with mallinfo2
@ 2023-03-20  6:07 Reini Urban
  2023-03-20 18:23 ` Andrew Pinski
  0 siblings, 1 reply; 2+ messages in thread
From: Reini Urban @ 2023-03-20  6:07 UTC (permalink / raw)
  To: gcc-patches


[-- Attachment #1.1: Type: text/plain, Size: 99 bytes --]

Fix sanititzers with mallinfo2
e.g fedora already uses mallinfo2 with long v[10];

-- 
Reini Urban

[-- Attachment #2: 0001-__sanitizer_struct_mallinfo-vs-mallinfo2-size-assert.patch --]
[-- Type: text/x-patch, Size: 1897 bytes --]

From 074b5b5d073137762a3bbef3cece5646cea537b5 Mon Sep 17 00:00:00 2001
From: Reini Urban <rurban@cpan.org>
Date: Sat, 12 Mar 2022 09:52:36 +0100
Subject: [PATCH 1/2] __sanitizer_struct_mallinfo vs mallinfo2 size assertion

libsanitizer/Changelog:
	* configure.ac: add mallinfo2 probe
	* sanitizer_common/sanitizer_platform_limits_posix.h
	(struct __sanitizer_struct_mallinfo): use mallinfo2 probe

Signed-off-by: Reini Urban <rurban@cpan.org>
---
 libsanitizer/configure.ac                                    | 3 ++-
 .../sanitizer_common/sanitizer_platform_limits_posix.h       | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git libsanitizer/configure.ac libsanitizer/configure.ac
index 04cd8910ed6..227c2644ecd 100644
--- libsanitizer/configure.ac
+++ libsanitizer/configure.ac
@@ -103,7 +103,8 @@ AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
 AM_CONDITIONAL(HWASAN_SUPPORTED, [test "x$HWASAN_SUPPORTED" = "xyes"])
 
 # Check for functions needed.
-AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime lstat readlink)
+AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime lstat readlink \
+	mallinfo mallinfo2)
 
 # Common libraries that we need to link against for all sanitizer libs.
 link_sanitizer_common='-lpthread -lm'
diff --git libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
index 44dd3d9e22d..918ee95ef82 100644
--- libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+++ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -213,7 +213,12 @@ struct __sanitizer_struct_mallinfo {
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
 struct __sanitizer_struct_mallinfo {
+  // e.g ubuntu uses mallinfo, fedora mallinfo2
+#ifdef HAVE_MALLINFO2
+  long v[10];
+#else
   int v[10];
+#endif
 };
 
 extern unsigned struct_ustat_sz;
-- 
2.34.1


[-- Attachment #3: 0002-gcc-fixup-report_heap_memory_use-without-mallinfo2-d.patch --]
[-- Type: text/x-patch, Size: 840 bytes --]

From 6e1ab452bcf2bae0be20faf65966c8ee2f755a2b Mon Sep 17 00:00:00 2001
From: Reini Urban <rurban@cpan.org>
Date: Sun, 20 Feb 2022 18:27:15 +0100
Subject: [PATCH 2/2] gcc: fixup report_heap_memory_use() without mallinfo2
 decl

gcc/ChangeLog:
	* gcc/ggc-common.cc (report_heap_memory_use): fix
	without mallinfo2 decl

Signed-off-by: Reini Urban <rurban@cpan.org>
---
 gcc/ggc-common.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git gcc/ggc-common.cc gcc/ggc-common.cc
index db317f49993..9cd446995f8 100644
--- gcc/ggc-common.cc
+++ gcc/ggc-common.cc
@@ -1276,7 +1276,7 @@ void
 report_heap_memory_use ()
 {
 #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
-#ifdef HAVE_MALLINFO2
+#if defined HAVE_MALLINFO2 && HAVE_DECL_MALLINFO2
   #define MALLINFO_FN mallinfo2
 #else
   #define MALLINFO_FN mallinfo
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fix for __sanitizer_struct_mallinfo with mallinfo2
  2023-03-20  6:07 [PATCH] fix for __sanitizer_struct_mallinfo with mallinfo2 Reini Urban
@ 2023-03-20 18:23 ` Andrew Pinski
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2023-03-20 18:23 UTC (permalink / raw)
  To: Reini Urban; +Cc: gcc-patches

On Sun, Mar 19, 2023 at 11:08 PM Reini Urban via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Fix sanititzers with mallinfo2
> e.g fedora already uses mallinfo2 with long v[10];

Parts of these patches should go upstream first.

Thanks,
Andrew

>
> --
> Reini Urban

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-20 18:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20  6:07 [PATCH] fix for __sanitizer_struct_mallinfo with mallinfo2 Reini Urban
2023-03-20 18:23 ` Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).