-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parameter to check if files are mapped in processes not part of t…
…he recording.
- Loading branch information
1 parent
d44565d
commit 1db6339
Showing
8 changed files
with
154 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "util.h" | ||
|
||
#include <assert.h> | ||
#include <fcntl.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <sys/stat.h> | ||
|
||
int main(__attribute__((unused)) int argc, char* argv[], char* argenv[]) { | ||
size_t page_size = sysconf(_SC_PAGESIZE); | ||
char last = 0; | ||
char* p; | ||
int proc_num = argv[2][0] - '0'; | ||
int timeout = 30000; // 30 seconds | ||
|
||
if (argv[3][0] > '0') { | ||
if (fork() == 0) { | ||
char proc_num_arg[2] = {'0' + proc_num + 1, '\0'}; | ||
char proc_to_start_arg[2] = {argv[3][0] - 1, '\0'}; | ||
char* execv_argv[] = {argv[0], argv[1], proc_num_arg, proc_to_start_arg, NULL}; | ||
execve("/proc/self/exe", execv_argv, argenv); | ||
} | ||
} | ||
|
||
int fd = open(argv[1], O_RDWR|O_CREAT, 0600); | ||
test_assert(fd >= 0); | ||
ftruncate(fd, page_size); | ||
p = (char*)mmap(0, page_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); | ||
assert(p != MAP_FAILED); | ||
|
||
while (1) { | ||
if ((*p % 2) == proc_num) { | ||
if ((*p)++ >= 6) { | ||
atomic_printf("%d %d exiting.\n", getpid(), proc_num); | ||
usleep(50000); /* first recorded process exiting kills all others, wait a little. */ | ||
return 0; | ||
} | ||
} | ||
if (last != *p) | ||
atomic_printf("%d\n", last = *p); | ||
usleep(50000); | ||
timeout -= 50; | ||
if (timeout < 0) { | ||
atomic_printf("timeout reached.\n"); | ||
return 0; | ||
} | ||
} | ||
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,25 @@ | ||
source `dirname $0`/util.sh | ||
|
||
skip_if_rr_32_bit_with_shell_64_bit | ||
|
||
rm -rf $workdir/map_file | ||
RECORD_ARGS="--check-outside-mmaps" | ||
record mmap_shared_extern$bitness $workdir/map_file 0 1 | ||
mv record.out record.out.1 | ||
mv record.err record.err.1 | ||
grep "could cause diversion" $workdir/record.out.1 > /dev/null | ||
if [[ $? != 1 ]]; then | ||
failed "\"could cause diversion\" was returned when all processes are inside the recording." | ||
exit | ||
fi | ||
|
||
rm -rf $workdir/map_file | ||
mmap_shared_extern$bitness $workdir/map_file 0 0 > /dev/null& | ||
RECORD_ARGS="--check-outside-mmaps" | ||
record mmap_shared_extern$bitness $workdir/map_file 1 0 | ||
mv record.out record.out.2 | ||
mv record.err record.err.2 | ||
grep "could cause diversion" $workdir/record.out.2 > /dev/null | ||
if [[ $? != 0 ]]; then | ||
failed "\"could cause diversion\" was not returned when some processes are outside the recording." | ||
fi |