Files
ftmemsim-valgrind/none/tests/amd64-linux/bug345887.c
Florian Krohm 9d3d254a8b 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
2015-04-23 15:20:00 +00:00

43 lines
1.1 KiB
C

/* 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;
}