]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
manpage: a few changes for realloc size zero and give FreeBSD a few mentions
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 9 Feb 2024 20:55:21 +0000 (21:55 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 9 Feb 2024 20:55:21 +0000 (21:55 +0100)
docs/xml/manual-core.xml
memcheck/docs/mc-manual.xml

index 296fc1c2a96a589169b0c3377572f27f9df11752..0985ac8673d295dadebbc4479e8d3c2b70da1363 100644 (file)
@@ -1795,11 +1795,15 @@ that can report errors, e.g. Memcheck, but not Cachegrind.</para>
       <para>The behaviour of <computeroutput>realloc()</computeroutput> 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 <option>yes</option> then <varname>realloc</varname> will
+      deallocate the memory and return NULL. If the value is <option>no</option> then
+      <varname>realloc</varname> will not deallocate the memory and
+      the size will be handled as though it were one byte.</para>
+      <para>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
       <computeroutput>--realloc-zero-bytes-frees=no</computeroutput>.
       </para>
       <para>Address Sanitizer has a similar and even wordier option
@@ -2013,7 +2017,7 @@ need to use them.</para>
       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
       <option>--read-inline-info=no</option>:
@@ -2143,7 +2147,8 @@ need to use them.</para>
       <option><![CDATA[--run-libc-freeres=<yes|no> [default: yes] ]]></option>
     </term>
     <listitem>
-      <para>This option is only relevant when running Valgrind on Linux.</para>
+      <para>This option is only relevant when running Valgrind on Linux with
+      GNU libc.</para>
 
       <para>The GNU C library (<function>libc.so</function>), which is
       used by all programs, may allocate memory for its own uses.
@@ -2177,8 +2182,8 @@ need to use them.</para>
       <option><![CDATA[--run-cxx-freeres=<yes|no> [default: yes] ]]></option>
     </term>
     <listitem>
-      <para>This option is only relevant when running Valgrind on Linux
-            or Solaris C++ programs.</para>
+      <para>This option is only relevant when running Valgrind on Linux,
+      FreeBSD or Solaris C++ programs using libstdc++.</para>
 
       <para>The GNU Standard C++ library (<function>libstdc++.so</function>),
       which is used by all C++ programs compiled with g++, may allocate memory
@@ -2698,13 +2703,6 @@ need to use them.</para>
           any shared library having no soname. </para>
         </listitem>
 
-        <listitem>
-          <para>To run a "default" Firefox build for Linux, in which
-          JEMalloc is linked in to the main executable,
-          use <option>--soname-synonyms=somalloc=NONE</option>.
-          </para>
-        </listitem>
-
        <listitem>
          <para>To only intercept allocation symbols in the default
          system libraries, but not in any other shared library or the
index aa9210f17ff25585ea78acafb08fcad2b7a61c49..7394e98e3db0690faaf8bcbacd48a34376a750f6 100644 (file)
@@ -1347,6 +1347,20 @@ is <option>--errors-for-leak-kinds=definite,possible</option>
     </listitem>
   </varlistentry>
 
+   <varlistentry id="opt.show-realloc-size-zero"
+                xreflabel="--show-realloc-size-zero">
+    <term>
+      <option><![CDATA[--show-realloc-size-zero=<yes|no> [default: yes] ]]></option>
+    </term>
+    <listitem>
+      <para>When enabled, Memcheck checks for uses of <varname>realloc</varname> with a size of zero.
+      This usage of <varname>realloc</varname> is unsafe since it is not portable. On some systems it
+      will behave like <varname>free</varname>. On other systems it will either do nothing or else
+      behave like a call to <varname>free</varname> followed by a call to <varname>malloc</varname>
+      with a size of zero.</para>
+    </listitem>
+  </varlistentry>
+
   <varlistentry id="opt.ignore-ranges" xreflabel="--ignore-ranges">
     <term>
       <option><![CDATA[--ignore-ranges=0xPP-0xQQ[,0xRR-0xSS] ]]></option>