[all-commits] [llvm/llvm-project] 8df3c7: sanitizer_common: sanitize time functions

Dmitry Vyukov via All-commits all-commits at lists.llvm.org
Sun Jul 11 03:10:05 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8df3c7ded26fb9ee1ecf5a5099da7645174a2e26
      https://github.com/llvm/llvm-project/commit/8df3c7ded26fb9ee1ecf5a5099da7645174a2e26
  Author: Dmitry Vyukov <dvyukov at google.com>
  Date:   2021-07-11 (Sun, 11 Jul 2021)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_common.h
    M compiler-rt/lib/sanitizer_common/sanitizer_common_nolibc.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_libc.h
    M compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_netbsd.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_win.cpp

  Log Message:
  -----------
  sanitizer_common: sanitize time functions

We have SleepForSeconds, SleepForMillis and internal_sleep.
Some are implemented in terms of libc functions, some -- in terms
of syscalls. Some are implemented in per OS files,
some -- in libc/nolibc files. That's unnecessary complex
and libc functions cause crashes in some contexts because
we intercept them. There is no single reason to have calls to libc
when we have syscalls (and we have them anyway).

Add internal_usleep that is implemented in terms of syscalls per OS.
Make SleepForSeconds/SleepForMillis/internal_sleep a wrapper
around internal_usleep that is implemented in sanitizer_common.cpp once.

Also remove return values for internal_sleep, it's not used anywhere.

Eventually it would be nice to remove SleepForSeconds/SleepForMillis/internal_sleep.
There is no point in having that many different names for the same thing.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D105718




More information about the All-commits mailing list