From: Tom Hughes Date: Fri, 4 Nov 2005 11:31:33 +0000 (+0000) Subject: When unwinding the stack on x86/amd64 subtract one from the value of X-Git-Tag: svn/VALGRIND_3_1_0~236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64a4375b1bf95277d981efec9499b2687229a0a6;p=thirdparty%2Fvalgrind.git When unwinding the stack on x86/amd64 subtract one from the value of ip before starting a new pass of the loop. The reason for this is that (except for the first pass of the loop) the value of ip is actually a return address, which is therefore after the instruction that was executing at the time. This means that if there is a boundary in the CFI information at that point we can wind up using the wrong CFI data to do the next unwind if we do it based on the return address. This most commonly happens with a tail call where we wind up using the data for the next function to do the unwind and getting hopelessly lost. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4996 --- diff --git a/coregrind/m_stacktrace.c b/coregrind/m_stacktrace.c index e9824883bc..62b83c29da 100644 --- a/coregrind/m_stacktrace.c +++ b/coregrind/m_stacktrace.c @@ -124,6 +124,7 @@ UInt VG_(get_StackTrace2) ( Addr* ips, UInt n_ips, ips[i++] = ip; if (debug) VG_(printf)(" ipsC[%d]=%08p\n", i-1, ips[i-1]); + ip = ip - 1; continue; } @@ -145,6 +146,7 @@ UInt VG_(get_StackTrace2) ( Addr* ips, UInt n_ips, ips[i++] = ip; if (debug) VG_(printf)(" ipsF[%d]=%08p\n", i-1, ips[i-1]); + ip = ip - 1; continue; }