From: Julian Seward Date: Tue, 7 Jul 2015 14:06:00 +0000 (+0000) Subject: VG_(get_StackTrace_wrk) for x86-{linux,darwin}: when following X-Git-Tag: svn/VALGRIND_3_11_0~245 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c9d03a09d21bf339ece4eb6b99d4afb2f3477a8;p=thirdparty%2Fvalgrind.git VG_(get_StackTrace_wrk) for x86-{linux,darwin}: when following frame-pointer chains (via EBP), don't continue if EBP doesn't contain a 4-aligned value. A misaligned EBP is almost certainly invalid -- hence, no loss in unwind capability here -- and the misaligned access causes gcc 5.1 ubsan alignment checks to fail. So avoid them. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15400 --- diff --git a/coregrind/m_stacktrace.c b/coregrind/m_stacktrace.c index 83dc5d9b8a..aca2d20fd8 100644 --- a/coregrind/m_stacktrace.c +++ b/coregrind/m_stacktrace.c @@ -337,7 +337,8 @@ UInt VG_(get_StackTrace_wrk) ( ThreadId tid_if_known, /* This deals with frames resulting from functions which begin "pushl% ebp ; movl %esp, %ebp" which is the ABI-mandated preamble. */ if (fp_min <= uregs.xbp && - uregs.xbp <= fp_max - 1 * sizeof(UWord)/*see comment below*/) + uregs.xbp <= fp_max - 1 * sizeof(UWord)/*see comment below*/ && + VG_IS_4_ALIGNED(uregs.xbp)) { /* fp looks sane, so use it. */ uregs.xip = (((UWord*)uregs.xbp)[1]);