From 1c9d03a09d21bf339ece4eb6b99d4afb2f3477a8 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 7 Jul 2015 14:06:00 +0000 Subject: [PATCH] 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 --- coregrind/m_stacktrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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]); -- 2.47.3