]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix 391861 - Massif Assertion 'n_ips >= 1 && n_ips <= VG_(clo_backtrace_size)'
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 21 Mar 2018 22:24:09 +0000 (23:24 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 21 Mar 2018 22:35:48 +0000 (23:35 +0100)
Sometimes, at least on arm platforms, we get a stack trace with
only one function.
When this happens and massif removes the top fn, we end up trying
to create an execontext of 0 ips, as the only fn is removed,
and an execontext of 0 ips causes the assert in m_execontext.c

So, do whatever to avoid to crash when having a single fn stacktrace.

The whatever means use a null execontext, which is an execontext
of one single address 0x0.
Note that this is just to bypass the crash.
What is shown by massif is not very nice (but what could we show ?).

Note that instead of using such a null execontext, we could rather
just keep the single ips. But that might create a lot of single fn
entries in the xtree and/or show undesired functions.

So, we the null execontext, which is shown as 0xFFFFFFFFFFFFFFFF ???
in the massif output.

Tested on amd64 by artificially creating stacktrace of one fn.

NEWS
massif/ms_main.c

diff --git a/NEWS b/NEWS
index f762530a92ae84013469cb126d547fe5091fa042..faee5cd6c4d2a6f3d27fbf66751615249c68f9bf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -100,6 +100,7 @@ where XXXXXX is the bug number as listed below.
 389373  exp-sgcheck the 'impossible' happened as Ist_LoadG is not instrumented
 389065  valgrind meets gcc flag -Wlogical-op
 390723  make xtree dump files world wide readable, similar to log files
+391861  Massif Assertion 'n_ips >= 1 && n_ips <= VG_(clo_backtrace_size)'
 
 n-i-bz  Fix missing workq_ops operations (macOS)
 n-i-bz  fix bug in strspn replacement
index 95ba944aca5c5ce0f8311e7dc07b8a451024db6a..b15fa5dd216cfad9b17c6063fdcacb4bbf17d84c 100644 (file)
@@ -587,12 +587,17 @@ static ExeContext* make_ec(ThreadId tid, Bool exclude_first_entry)
                                     NULL/*array to dump SP values in*/,
                                     NULL/*array to dump FP values in*/,
                                     0/*first_ip_delta*/ );
-   if (exclude_first_entry && n_ips > 0) {
-      const HChar *fnname;
-      VERB(4, "removing top fn %s from stacktrace\n", 
+   if (exclude_first_entry) {
+      if (n_ips > 1) {
+         const HChar *fnname;
+         VERB(4, "removing top fn %s from stacktrace\n",
               VG_(get_fnname)(VG_(current_DiEpoch)(), ips[0], &fnname)
-                 ? fnname : "???");
-      return VG_(make_ExeContext_from_StackTrace)(ips+1, n_ips-1);
+              ? fnname : "???");
+         return VG_(make_ExeContext_from_StackTrace)(ips+1, n_ips-1);
+      } else {
+         VERB(4, "null execontext as removing top fn with n_ips %d\n", n_ips);
+         return VG_(null_ExeContext) ();
+      }
    } else
       return VG_(make_ExeContext_from_StackTrace)(ips, n_ips);
 }