Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an assertion in the address space manager. BZ #345887.
The VG_(extend_stack) call needs to be properly guarded because the passed-in address is not necessarily part of an extensible stack segment. And an extensible stack segment is the only thing that function should have to deal with. Previously, the function VG_(am_addr_is_in_extensible_client_stack) was introduced to guard VG_(extend_stack) but it was not added in all places it should have been. Also, extending the client stack during signal delivery (in sigframe-common.c) was simply calling VG_(extend_stack) hoping it would do the right thing. But that was not always the case. The new testcase none/tests/linux/pthread-stack.c exercises this (3.10.1 errors out on it). Renamed ML_(sf_extend_stack) to ML_(sf_maybe_extend_stack) and add proper guard logic for VG_(extend_stack). Testcases none/tests/{amd64|x86}-linux/bug345887.c by Ivo Raisr. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15138 a5019735-40e9-0310-863c-91ae7b9d1cf9
- Loading branch information
florian
committed
Apr 23, 2015
1 parent
13172df
commit 50652d0
Showing
33 changed files
with
334 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
include $(top_srcdir)/Makefile.tool-tests.am | ||
|
||
dist_noinst_SCRIPTS = \ | ||
filter_stderr filter_minimal | ||
|
||
EXTRA_DIST = \ | ||
bug345887.stderr.exp bug345887.vgtest | ||
|
||
check_PROGRAMS = \ | ||
bug345887 | ||
|
||
AM_CFLAGS += @FLAG_M64@ | ||
AM_CXXFLAGS += @FLAG_M64@ | ||
AM_CCASFLAGS += @FLAG_M64@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* This test used to cause an assertion in the address space manager */ | ||
|
||
__attribute__((noinline)) | ||
static void inner(void) | ||
{ | ||
/* Set registers to apriori known values. */ | ||
__asm__ __volatile__( | ||
"movq $0x101, %%rax\n" | ||
"movq $0x102, %%rbx\n" | ||
"movq $0x103, %%rcx\n" | ||
"movq $0x104, %%rdx\n" | ||
"movq $0x105, %%rsi\n" | ||
"movq $0x106, %%rdi\n" | ||
"movq $0x107, %%r8\n" | ||
"movq $0x108, %%r9\n" | ||
"movq $0x109, %%r10\n" | ||
"movq $0x10a, %%r11\n" | ||
"movq $0x10b, %%r12\n" | ||
"movq $0x10c, %%r13\n" | ||
"movq $0x10d, %%r14\n" | ||
"movq $0x10e, %%r15\n" | ||
// not %rbp as mdb is then not able to reconstruct stack trace | ||
"movq $0x10f, %%rsp\n" | ||
"movq $0x1234, (%%rax)\n" // should cause SEGV here | ||
"ud2" // should never get here | ||
: // no output registers | ||
: // no input registers | ||
: "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", | ||
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", "%rsp"); | ||
} | ||
|
||
__attribute__((noinline)) | ||
static void outer(void) | ||
{ | ||
inner(); | ||
} | ||
|
||
int main(int argc, const char *argv[]) | ||
{ | ||
outer(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
Process terminating with default action of signal 11 (SIGSEGV) | ||
Access not within mapped region at address 0x........ | ||
at 0x........: inner (bug345887.c:7) | ||
If you believe this happened as a result of a stack | ||
overflow in your program's main thread (unlikely but | ||
possible), you can try to increase the size of the | ||
main thread stack using the --main-stacksize= flag. | ||
The main thread stack size used in this run was .... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
prog: bug345887 | ||
vgopts: -q | ||
stderr_filter: filter_minimal | ||
cleanup: rm -f vgcore.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/sh | ||
|
||
dir=`dirname $0` | ||
|
||
# Remove ==pid== and **pid** strings | ||
perl -p -e 's/(==|\*\*)[0-9]{1,7}\1 //' | | ||
|
||
perl -p -e 's/0x[0-9A-Fa-f]+/0x......../g' | | ||
|
||
# Older bash versions print abnormal termination messages on the stderr | ||
# of the bash process. Newer bash versions redirect such messages properly. | ||
# Suppress any redirected abnormal termination messages. You can find the | ||
# complete list of messages in the bash source file siglist.c. | ||
perl -n -e 'print if !/^(Segmentation fault|Alarm clock|Aborted|Bus error)( \(core dumped\))?$/' | | ||
|
||
# Remove the size in "The main thread stack size..." message. | ||
sed "s/The main thread stack size used in this run was [0-9]*/The main thread stack size used in this run was .../" | ||
|
||
# NOTE: it is essential for the bug345887 testcase that the stderr | ||
# filtering does *not* remove lines beginning with -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /bin/sh | ||
|
||
dir=`dirname $0` | ||
|
||
# Remove ==pid== and --pid-- and **pid** strings | ||
perl -p -e 's/(==|--|\*\*)[0-9]{1,7}\1 //' | | ||
|
||
perl -p -e 's/0x[0-9A-Fa-f]+/0x......../g' | ||
|
||
# NOTE: it is essential for the bug345887 testcase that the stderr | ||
# filtering does *not* remove lines beginning with -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.