mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
Add a test case for #156404 (main thread stack not getting extended
downwards properly at syscalls). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8718
This commit is contained in:
parent
b766fb30aa
commit
5aecd38266
@ -21,6 +21,8 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
|
||||
bug137714-amd64.vgtest bug137714-amd64.stdout.exp \
|
||||
bug137714-amd64.stderr.exp \
|
||||
bug132918.vgtest bug132918.stderr.exp bug132918.stdout.exp \
|
||||
bug156404-amd64.vgtest bug156404-amd64.stdout.exp \
|
||||
bug156404-amd64.stderr.exp \
|
||||
clc.vgtest clc.stdout.exp clc.stderr.exp \
|
||||
faultstatus.disabled faultstatus.stderr.exp \
|
||||
fcmovnu.vgtest fcmovnu.stderr.exp fcmovnu.stdout.exp \
|
||||
@ -47,6 +49,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
|
||||
|
||||
check_PROGRAMS = \
|
||||
bug127521-64 bug132813-amd64 bug137714-amd64 bug132918 \
|
||||
bug156404-amd64 \
|
||||
clc \
|
||||
faultstatus fcmovnu fxtract $(INSN_TESTS) looper jrcxz \
|
||||
rcl-amd64 \
|
||||
|
||||
56
none/tests/amd64/bug156404-amd64.c
Normal file
56
none/tests/amd64/bug156404-amd64.c
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
/* Check that the main thread's stack, on Linux, is automatically
|
||||
extended down to the lowest valid address when a syscall happens.
|
||||
Failure to do so was causing this test to fail on Linux amd64. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define VG_STRINGIFZ(__str) #__str
|
||||
#define VG_STRINGIFY(__str) VG_STRINGIFZ(__str)
|
||||
|
||||
#define __NR_READLINK VG_STRINGIFY(__NR_readlink)
|
||||
|
||||
extern long my_readlink ( const char* path );
|
||||
asm(
|
||||
".text\n"
|
||||
".globl my_readlink\n"
|
||||
"my_readlink:\n"
|
||||
"\tsubq $0x1008,%rsp\n"
|
||||
"\tmovq %rdi,%rdi\n" // path is in rdi
|
||||
"\tmovq %rsp,%rsi\n" // &buf[0] -> rsi
|
||||
"\tmovl $0x1000,%edx\n" // sizeof(buf) in rdx
|
||||
"\tmovl $"__NR_READLINK",%eax\n" // syscall number
|
||||
"\tsyscall\n"
|
||||
"\taddq $0x1008,%rsp\n"
|
||||
"\tret\n"
|
||||
".previous\n"
|
||||
);
|
||||
|
||||
long recurse ( const char* path, long count )
|
||||
{
|
||||
if (count <= 0) {
|
||||
return my_readlink(path);
|
||||
} else {
|
||||
long r = recurse(path, count-1);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
int main ( void )
|
||||
{
|
||||
long i, r;
|
||||
for (i = 0; i < 2000; i++) {
|
||||
printf("depth %ld: ", i );
|
||||
r = recurse( "/proc/self", i );
|
||||
if (r > 1) r = 1; /* to make the output repeatable */
|
||||
assert(r >= 1);
|
||||
printf("r = %ld\n", r);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
2
none/tests/amd64/bug156404-amd64.stderr.exp
Normal file
2
none/tests/amd64/bug156404-amd64.stderr.exp
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
2000
none/tests/amd64/bug156404-amd64.stdout.exp
Normal file
2000
none/tests/amd64/bug156404-amd64.stdout.exp
Normal file
File diff suppressed because it is too large
Load Diff
1
none/tests/amd64/bug156404-amd64.vgtest
Normal file
1
none/tests/amd64/bug156404-amd64.vgtest
Normal file
@ -0,0 +1 @@
|
||||
prog: bug156404-amd64
|
||||
Loading…
x
Reference in New Issue
Block a user