public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Reini Urban <reini.urban@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] fix for __sanitizer_struct_mallinfo with mallinfo2
Date: Mon, 20 Mar 2023 07:07:52 +0100	[thread overview]
Message-ID: <CAHiT=DHPmR-Rs2vT4hbq0pvPsbMthqpFPtfJ6GAUHhWxf31mLg@mail.gmail.com> (raw)


[-- 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


             reply	other threads:[~2023-03-20  6:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20  6:07 Reini Urban [this message]
2023-03-20 18:23 ` Andrew Pinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHiT=DHPmR-Rs2vT4hbq0pvPsbMthqpFPtfJ6GAUHhWxf31mLg@mail.gmail.com' \
    --to=reini.urban@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).