-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sanitizer] Support running without fd 0,1,2.
Summary: Support running with no open file descriptors (as may happen to "init" process on linux). * Remove a check that writing to stderr succeeds. * When opening a file (ex. for log_path option), dup the new fd out of [0, 2] range to avoid confusing the program. (2nd attempt, this time without the sanitizer_rtems change) Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55801 llvm-svn: 349817
- Loading branch information
Showing
7 changed files
with
75 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,39 @@ | ||
| // RUN: %clangxx_asan -O0 %s -o %t | ||
| // RUN: %run %t 2>&1 | FileCheck %s | ||
| // RUN: %env_asan_opts=debug=1,verbosity=2 %run %t 2>&1 | FileCheck %s | ||
|
|
||
| // Test ASan initialization | ||
|
|
||
| #include <assert.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <unistd.h> | ||
|
|
||
| void parent(int argc, char **argv) { | ||
| fprintf(stderr, "hello\n"); | ||
| // CHECK: hello | ||
| close(0); | ||
| close(1); | ||
| dup2(2, 3); | ||
| close(2); | ||
| char *const newargv[] = {argv[0], (char *)"x", nullptr}; | ||
| execv(argv[0], newargv); | ||
| perror("execve"); | ||
| exit(1); | ||
| } | ||
|
|
||
| void child() { | ||
| assert(dup(3) == 0); | ||
| assert(dup(3) == 1); | ||
| assert(dup(3) == 2); | ||
| fprintf(stderr, "world\n"); | ||
| // CHECK: world | ||
| } | ||
|
|
||
| int main(int argc, char **argv) { | ||
| if (argc == 1) { | ||
| parent(argc, argv); | ||
| } else { | ||
| child(); | ||
| } | ||
| } |