Bug 1024162

Summary: valgrind causes crashes in signal handlers on x86_64
Product: Red Hat Enterprise Linux 6 Reporter: Tom Lane <tgl>
Component: valgrindAssignee: Mark Wielaard <mjw>
Status: CLOSED ERRATA QA Contact: Miloš Prchlík <mprchlik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.4CC: jakub, jherrman, mbenitez, mfranc, mprchlik
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
URL: https://bugs.kde.org/show_bug.cgi?id=280114
Whiteboard:
Fixed In Version: valgrind-3.8.1-3.3.el6 Doc Type: Bug Fix
Doc Text:
Prior to this update, Red Hat Enterprise Linux 6 signal handlers were executed on a misaligned stack when used on the AMD64 and Intel 64 architectures. Consequently, instructions that require 16-byte data alignment terminated unexpectedly. This update fixes the stack pointer alignment and now, invoking a signal on the AMD64 and Intel 64 architectures is executed properly.
Story Points: ---
Clone Of:
: 1026230 (view as bug list) Environment:
Last Closed: 2014-10-14 06:36:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1026230, 1056252    

Description Tom Lane 2013-10-29 03:09:53 UTC
Description of problem:
I'd like to lobby for valgrind upstream's revision 13182 to be included into RHEL6.  It looks like this:

$ svn diff -c 13182
Index: coregrind/m_sigframe/sigframe-amd64-linux.c
===================================================================
--- coregrind/m_sigframe/sigframe-amd64-linux.c (revision 13181)
+++ coregrind/m_sigframe/sigframe-amd64-linux.c (revision 13182)
@@ -452,7 +452,7 @@
    UWord err;
 
    rsp -= sizeof(*frame);
-   rsp = VG_ROUNDDN(rsp, 16);
+   rsp = VG_ROUNDDN(rsp, 16) - 8;
    frame = (struct rt_sigframe *)rsp;
 
    if (!extend(tst, rsp, sizeof(*frame)))

Without this, signal handlers are executed on a misaligned stack, and so
instructions that require correct 16-byte alignment dump core.

I see that this behavior was previously reported as rhbz #950585, which was
closed WONTFIX apparently because it was thought to be a Postgres-specific problem.  It isn't, though I'll admit that I'm griping mainly because this is preventing me from using valgrind on Postgres.

Version-Release number of selected component (if applicable):
valgrind-3.8.1-3.2.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
There's a reproducer included in https://bugs.kde.org/show_bug.cgi?id=280114
where the issue was first diagnosed.

Comment 2 Mark Wielaard 2013-10-29 09:09:12 UTC
Full upstream commit log describes this as:

    Make sure the stack pointer is properly aligned when invoking a
    signal on amd64-linux systems.
    
    The amd64 ABI describes the required alignment on function entry
    as follows:
    
      "In other words, the value (%rsp − 8) is always a multiple
       of 16 when control is transferred to the function entry point.
    
    So we need to 16 byte align and then subtract an extra 8 bytes
    to achieve the correct alignment.
    
    Patch from fjgmacc to fix BZ#280114.

The upstream bug report has a very small SIGALRM based testcase for this.

Comment 4 Miloš Prchlík 2014-06-03 12:26:00 UTC
Verified for build valgrind-3.8.1-3.5.el6.

Comment 5 errata-xmlrpc 2014-10-14 06:36:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1464.html