summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-07-24 02:34:24 +0000
committerPetr Hosek <phosek@chromium.org>2018-07-24 02:34:24 +0000
commit471e11a661c97bcb950a1200f2cf2565a5ba55bc (patch)
treea94de4144cd84dec1c2b78b70d6a9656afad1335
parent4d01f6e9762aaa1f5a458c1d3c5fb2959ad22079 (diff)
[sanitizer][fuzzer] Temporarily transition to ZX_TIME_INFINITE_OLD
This is a preparation for breaking change when all Zircon calls that take time as an argument will start using signed valued. We will transition back to ZX_TIME_INFITINE after all the changes to these symbols are done and become part of the Fuchsia SDK. Differential Revision: https://reviews.llvm.org/D49694 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337802 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/fuzzer/FuzzerUtilFuchsia.cpp11
-rw-r--r--lib/sanitizer_common/sanitizer_fuchsia.cc5
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/fuzzer/FuzzerUtilFuchsia.cpp b/lib/fuzzer/FuzzerUtilFuchsia.cpp
index b9c70e461..cd2bb7438 100644
--- a/lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ b/lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -49,6 +49,9 @@ void CrashTrampolineAsm() __asm__("CrashTrampolineAsm");
namespace {
+// TODO(phosek): remove this and replace it with ZX_TIME_INFINITE
+#define ZX_TIME_INFINITE_OLD INT64_MAX
+
// A magic value for the Zircon exception port, chosen to spell 'FUZZING'
// when interpreted as a byte sequence on little-endian platforms.
const uint64_t kFuzzingCrash = 0x474e495a5a5546;
@@ -234,7 +237,7 @@ void CrashHandler(zx_handle_t *Event) {
"_zx_object_signal");
zx_port_packet_t Packet;
- ExitOnErr(_zx_port_wait(Port.Handle, ZX_TIME_INFINITE, &Packet),
+ ExitOnErr(_zx_port_wait(Port.Handle, ZX_TIME_INFINITE_OLD, &Packet),
"_zx_port_wait");
// At this point, we want to get the state of the crashing thread, but
@@ -312,8 +315,8 @@ void SetSignalHandler(const FuzzingOptions &Options) {
ExitOnErr(_zx_event_create(0, &Event), "_zx_event_create");
std::thread T(CrashHandler, &Event);
- zx_status_t Status =
- _zx_object_wait_one(Event, ZX_USER_SIGNAL_0, ZX_TIME_INFINITE, nullptr);
+ zx_status_t Status = _zx_object_wait_one(Event, ZX_USER_SIGNAL_0,
+ ZX_TIME_INFINITE_OLD, nullptr);
_zx_handle_close(Event);
ExitOnErr(Status, "_zx_object_wait_one");
@@ -437,7 +440,7 @@ int ExecuteCommand(const Command &Cmd) {
// Now join the process and return the exit status.
if ((rc = _zx_object_wait_one(ProcessHandle, ZX_PROCESS_TERMINATED,
- ZX_TIME_INFINITE, nullptr)) != ZX_OK) {
+ ZX_TIME_INFINITE_OLD, nullptr)) != ZX_OK) {
Printf("libFuzzer: failed to join '%s': %s\n", Argv[0],
_zx_status_get_string(rc));
return rc;
diff --git a/lib/sanitizer_common/sanitizer_fuchsia.cc b/lib/sanitizer_common/sanitizer_fuchsia.cc
index 7b29ae9ae..391620690 100644
--- a/lib/sanitizer_common/sanitizer_fuchsia.cc
+++ b/lib/sanitizer_common/sanitizer_fuchsia.cc
@@ -29,6 +29,9 @@
namespace __sanitizer {
+// TODO(phosek): remove this and replace it with ZX_TIME_INFINITE
+#define ZX_TIME_INFINITE_OLD INT64_MAX
+
void NORETURN internal__exit(int exitcode) { _zx_process_exit(exitcode); }
uptr internal_sched_yield() {
@@ -120,7 +123,7 @@ void BlockingMutex::Lock() {
return;
while (atomic_exchange(m, MtxSleeping, memory_order_acquire) != MtxUnlocked) {
zx_status_t status = _zx_futex_wait(reinterpret_cast<zx_futex_t *>(m),
- MtxSleeping, ZX_TIME_INFINITE);
+ MtxSleeping, ZX_TIME_INFINITE_OLD);
if (status != ZX_ERR_BAD_STATE) // Normal race.
CHECK_EQ(status, ZX_OK);
}