Bug 280114

Summary: general protection fail reported in signal handler
Product: [Developer tools] valgrind Reporter: fjgmacc
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: andres+bugs.kde.org, tom
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: source of test program showing fault
Considerably simpler testcase.

Description fjgmacc 2011-08-15 09:45:59 UTC
Created attachment 62839 [details]
source of test program showing fault

Version:           unspecified
OS:                Linux

source code v3.6.1 from Valgrind site.

program fails with gpf under valgrind - in signal handler.
failing instruction is moveaps which requires 16 byte alignment - stack in signal handler is 8 byte aligned.

run without valgrind , stack is 16 byte aligned and program runs o.k.

Reproducible: Always

Steps to Reproduce:
 g++ -m64 -lrt  -ggdb  <source>

run - no arguments

Actual Results:  
gpf

Expected Results:  
program runs - no output.

problem is fixed by the following change :

 diff valgrind/valgrind-3.6.1/coregrind/m_sigframe/sigframe-amd64-linux.c valgrind/valgrind-3.6.1/coregrind/m_sigframe/sigframe-amd64-linux.c.orig
454c454
<    rsp = VG_ROUNDDN(rsp, 16) - 8;
---
>    rsp = VG_ROUNDDN(rsp, 16);
Comment 1 Andres Freund 2012-12-15 20:46:49 UTC
Created attachment 75852 [details]
Considerably simpler testcase.
Comment 2 Andres Freund 2012-12-15 20:52:21 UTC
This bug is still current as of r13180 and I can confirm that the OP's patch fixes it. Given the requirement that (%RSP - 8)  needs to be aligned to 16 bytes (System V Application Binary Interface - AMD64 Architecture Processor Supplement, 3.2.2) it seems to be the obvious fix.

Took a whole afternoon to track down (thanks to Tom Hughes on IRC), just to find its already been reported & fixed but just not yet applied...
Comment 3 Tom Hughes 2012-12-16 09:53:01 UTC
Fix committed as r13182.