Now that we have unit tests for the backtrace* functions, let's see what
they produce:

* I see a test failure on FreeBSD 12.0/i386: The returned size is not in range,
  it is (size_t)(-1).
  The test passes on FreeBSD 14.0/i386.
  In the FreeBSD git history, I can see that the bug fix was in commit
  895a7e604db4ddf2b5d58833a82c2b4956585d02. That is, the last FreeBSD release
  in which it should be reproducible is 12.4.

* An empty stack trace is produced in
  - FreeBSD 11.0/i386.
  - FreeBSD 12.2/sparc64.

* Instead of a truncated stack trace, an empty stack trace is returned on
  FreeBSD (all tested versions from 11.0 to 14.0),
  NetBSD (all tested versions from 7.0 to 10.0),
  OpenBSD (all tested versions from 7.0 to 7.5).

* The strings printed by backtrace_symbols_fd are not consistent with
  backtrace_symbols, on glibc (all tested versions, up to 2.39).

I have reported the glibc bug.

Collin, feel free to report the FreeBSD, NetBSD, OpenBSD bugs if you have
time for that. It's only by reporting bugs that we can trigger that they get
fixed.


2024-05-12  Bruno Haible  <br...@clisp.org>

        execinfo: Document known bugs.
        * doc/glibc-functions/backtrace.texi: Mention the various bugs on
        FreeBSD, NetBSD, OpenBSD.
        * doc/glibc-functions/backtrace_symbols_fd.texi: Mention the glibc bug.

diff --git a/doc/glibc-functions/backtrace.texi 
b/doc/glibc-functions/backtrace.texi
index b9a56094c1..ef2a3ac657 100644
--- a/doc/glibc-functions/backtrace.texi
+++ b/doc/glibc-functions/backtrace.texi
@@ -32,6 +32,16 @@
 The second argument is of type @code{size_t}, not @code{int}, on some 
platforms:
 FreeBSD, NetBSD, OpenBSD.
 @item
+The return value may be @code{(size_t)(-1)} instead of 0 on some platforms:
+FreeBSD 12.4/i386.
+@item
+The returned stack trace is empty if it would not entirely fit into the
+provided buffer on some platforms:
+FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5.
+@item
+The returned stack trace is always empty on some platforms:
+FreeBSD 11.0/i386, FreeBSD 12.2/sparc64.
+@item
 On platforms where the function is missing,
 the Gnulib substitute implementation is just a stub, and does nothing.
 @end itemize
diff --git a/doc/glibc-functions/backtrace_symbols_fd.texi 
b/doc/glibc-functions/backtrace_symbols_fd.texi
index fe97b44b35..71461ebcac 100644
--- a/doc/glibc-functions/backtrace_symbols_fd.texi
+++ b/doc/glibc-functions/backtrace_symbols_fd.texi
@@ -32,6 +32,11 @@
 The second argument is of type @code{size_t}, not @code{int}, on some 
platforms:
 FreeBSD, NetBSD, OpenBSD.
 @item
+The strings printed by this function not the same as the strings returned by
+@code{backtrace_symbols} on some platforms:
+@c https://sourceware.org/bugzilla/show_bug.cgi?id=31730
+glibc 2.39.
+@item
 On platforms where the function is missing,
 the Gnulib substitute implementation is just a stub, and does nothing.
 @end itemize




Reply via email to