From 62cda3da36ec851d3d0e8eba2e228c6124459f65 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Fri, 9 Feb 2024 21:55:21 +0100 Subject: [PATCH] manpage: a few changes for realloc size zero and give FreeBSD a few mentions --- docs/xml/manual-core.xml | 30 ++++++++++++++---------------- memcheck/docs/mc-manual.xml | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 296fc1c2a9..0985ac8673 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -1795,11 +1795,15 @@ that can report errors, e.g. Memcheck, but not Cachegrind. The behaviour of realloc() is implementation defined (in C17, in C23 it is likely to become undefined). Valgrind tries to work in the same way as the - underlying OS and C runtime library. However, if you use a - different C runtime library then this default may be wrong. - For instance, if you use Valgrind on Linux installed via a package - and use the musl C runtime or the JEMalloc library then - consider using + underlying system and C runtime library that it was configured and built on. + However, if you use a different C runtime library then this default may be wrong. + If the value is then realloc will + deallocate the memory and return NULL. If the value is then + realloc will not deallocate the memory and + the size will be handled as though it were one byte. + As an example, if you use Valgrind installed via a package on a + Linux distro using GNU libc but link your test executable with musl libc or + the JEMalloc library then consider using --realloc-zero-bytes-frees=no. Address Sanitizer has a similar and even wordier option @@ -2013,7 +2017,7 @@ need to use them. startup and makes it use more memory (typically for each inlined piece of code, 6 words and space for the function name), but it results in more descriptive stacktraces. Currently, - this functionality is enabled by default only for Linux, + this functionality is enabled by default only for Linux, FreeBSD, Android and Solaris targets and only for the tools Memcheck, Massif, Helgrind and DRD. Here is an example of some stacktraces with : @@ -2143,7 +2147,8 @@ need to use them. - This option is only relevant when running Valgrind on Linux. + This option is only relevant when running Valgrind on Linux with + GNU libc. The GNU C library (libc.so), which is used by all programs, may allocate memory for its own uses. @@ -2177,8 +2182,8 @@ need to use them. - This option is only relevant when running Valgrind on Linux - or Solaris C++ programs. + This option is only relevant when running Valgrind on Linux, + FreeBSD or Solaris C++ programs using libstdc++. The GNU Standard C++ library (libstdc++.so), which is used by all C++ programs compiled with g++, may allocate memory @@ -2698,13 +2703,6 @@ need to use them. any shared library having no soname. - - To run a "default" Firefox build for Linux, in which - JEMalloc is linked in to the main executable, - use . - - - To only intercept allocation symbols in the default system libraries, but not in any other shared library or the diff --git a/memcheck/docs/mc-manual.xml b/memcheck/docs/mc-manual.xml index aa9210f17f..7394e98e3d 100644 --- a/memcheck/docs/mc-manual.xml +++ b/memcheck/docs/mc-manual.xml @@ -1347,6 +1347,20 @@ is + + + + + + When enabled, Memcheck checks for uses of realloc with a size of zero. + This usage of realloc is unsafe since it is not portable. On some systems it + will behave like free. On other systems it will either do nothing or else + behave like a call to free followed by a call to malloc + with a size of zero. + + + -- 2.47.2