forked from OSchip/llvm-project
[Sanitizer] use raw syscall instead of _exit() function on Linux
llvm-svn: 175622
This commit is contained in:
parent
5c3e21ba55
commit
aadd1f2ad6
|
@ -435,9 +435,9 @@ class ScopedInErrorReport {
|
|||
// an error report will finish doing it.
|
||||
SleepForSeconds(Max(100, flags()->sleep_before_dying + 1));
|
||||
}
|
||||
// If we're still not dead for some reason, use raw Exit() instead of
|
||||
// If we're still not dead for some reason, use raw _exit() instead of
|
||||
// Die() to bypass any additional checks.
|
||||
Exit(flags()->exitcode);
|
||||
internal__exit(flags()->exitcode);
|
||||
}
|
||||
ASAN_ON_ERROR();
|
||||
reporting_thread_tid = asanThreadRegistry().GetCurrentTidOrInvalid();
|
||||
|
|
|
@ -51,7 +51,7 @@ static void AsanDie() {
|
|||
death_callback();
|
||||
if (flags()->abort_on_error)
|
||||
Abort();
|
||||
Exit(flags()->exitcode);
|
||||
internal__exit(flags()->exitcode);
|
||||
}
|
||||
|
||||
static void AsanCheckFailed(const char *file, int line, const char *cond,
|
||||
|
|
|
@ -45,7 +45,7 @@ void NORETURN Die() {
|
|||
if (DieCallback) {
|
||||
DieCallback();
|
||||
}
|
||||
Exit(1);
|
||||
internal__exit(1);
|
||||
}
|
||||
|
||||
static CheckFailedCallbackType CheckFailedCallback;
|
||||
|
|
|
@ -140,7 +140,6 @@ void SortArray(uptr *array, uptr size);
|
|||
|
||||
// Exit
|
||||
void NORETURN Abort();
|
||||
void NORETURN Exit(int exitcode);
|
||||
void NORETURN Die();
|
||||
void NORETURN SANITIZER_INTERFACE_ATTRIBUTE
|
||||
CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2);
|
||||
|
|
|
@ -45,6 +45,7 @@ char *internal_strrchr(const char *s, int c);
|
|||
char *internal_strstr(const char *haystack, const char *needle);
|
||||
// Works only for base=10 and doesn't set errno.
|
||||
s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
|
||||
int internal_snprintf(char *buffer, uptr length, const char *format, ...);
|
||||
|
||||
// Return true if all bytes in [mem, mem+size) are zero.
|
||||
// Optimized for the case when the result is true.
|
||||
|
@ -70,14 +71,15 @@ fd_t internal_open(const char *filename, int flags, u32 mode);
|
|||
|
||||
uptr internal_read(fd_t fd, void *buf, uptr count);
|
||||
uptr internal_write(fd_t fd, const void *buf, uptr count);
|
||||
|
||||
// OS
|
||||
uptr internal_filesize(fd_t fd); // -1 on error.
|
||||
int internal_stat(const char *path, void *buf);
|
||||
int internal_lstat(const char *path, void *buf);
|
||||
int internal_fstat(fd_t fd, void *buf);
|
||||
|
||||
int internal_dup2(int oldfd, int newfd);
|
||||
uptr internal_readlink(const char *path, char *buf, uptr bufsize);
|
||||
int internal_snprintf(char *buffer, uptr length, const char *format, ...);
|
||||
void NORETURN internal__exit(int exitcode);
|
||||
|
||||
// Threading
|
||||
int internal_sched_yield();
|
||||
|
|
|
@ -140,6 +140,11 @@ int internal_sched_yield() {
|
|||
return syscall(__NR_sched_yield);
|
||||
}
|
||||
|
||||
void internal__exit(int exitcode) {
|
||||
syscall(__NR_exit_group, exitcode);
|
||||
Die(); // Unreachable.
|
||||
}
|
||||
|
||||
// ----------------- sanitizer_common.h
|
||||
bool FileExists(const char *filename) {
|
||||
#if SANITIZER_LINUX_USES_64BIT_SYSCALLS
|
||||
|
|
|
@ -106,6 +106,10 @@ int internal_sched_yield() {
|
|||
return sched_yield();
|
||||
}
|
||||
|
||||
void internal__exit(int exitcode) {
|
||||
_exit(exitcode);
|
||||
}
|
||||
|
||||
// ----------------- sanitizer_common.h
|
||||
bool FileExists(const char *filename) {
|
||||
struct stat st;
|
||||
|
|
|
@ -209,10 +209,6 @@ void SleepForMillis(int millis) {
|
|||
usleep(millis * 1000);
|
||||
}
|
||||
|
||||
void Exit(int exitcode) {
|
||||
_exit(exitcode);
|
||||
}
|
||||
|
||||
void Abort() {
|
||||
abort();
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ bool StartSymbolizerSubprocess(const char *path_to_symbolizer,
|
|||
for (int fd = getdtablesize(); fd > 2; fd--)
|
||||
internal_close(fd);
|
||||
execl(path_to_symbolizer, path_to_symbolizer, (char*)0);
|
||||
Exit(1);
|
||||
internal__exit(1);
|
||||
}
|
||||
|
||||
// Continue execution in parent process.
|
||||
|
|
|
@ -167,10 +167,6 @@ void SleepForMillis(int millis) {
|
|||
Sleep(millis);
|
||||
}
|
||||
|
||||
void Exit(int exitcode) {
|
||||
_exit(exitcode);
|
||||
}
|
||||
|
||||
void Abort() {
|
||||
abort();
|
||||
_exit(-1); // abort is not NORETURN on Windows.
|
||||
|
@ -257,6 +253,10 @@ int internal_sched_yield() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void internal__exit(int exitcode) {
|
||||
_exit(exitcode);
|
||||
}
|
||||
|
||||
// ---------------------- BlockingMutex ---------------- {{{1
|
||||
const uptr LOCK_UNINITIALIZED = 0;
|
||||
const uptr LOCK_READY = (uptr)-1;
|
||||
|
|
Loading…
Reference in New Issue