Bug 280114 - general protection fail reported in signal handler
Summary: general protection fail reported in signal handler
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: unspecified
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-15 09:45 UTC by fjgmacc
Modified: 2012-12-16 09:53 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
source of test program showing fault (3.02 KB, text/plain)
2011-08-15 09:45 UTC, fjgmacc
Details
Considerably simpler testcase. (270 bytes, text/x-csrc)
2012-12-15 20:46 UTC, Andres Freund
Details

Note You need to log in before you can comment on or make changes to this bug.
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.