From: Philippe Waroquiers Date: Wed, 21 Mar 2018 22:24:09 +0000 (+0100) Subject: Fix 391861 - Massif Assertion 'n_ips >= 1 && n_ips <= VG_(clo_backtrace_size)' X-Git-Tag: VALGRIND_3_14_0~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c9bd311660bf4c1f9228519223214b6a50935ec;p=thirdparty%2Fvalgrind.git Fix 391861 - Massif Assertion 'n_ips >= 1 && n_ips <= VG_(clo_backtrace_size)' 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. --- diff --git a/NEWS b/NEWS index f762530a92..faee5cd6c4 100644 --- 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 diff --git a/massif/ms_main.c b/massif/ms_main.c index 95ba944aca..b15fa5dd21 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -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); }