Fix peak RSS calculation on macOS in FuzzTest watchdog. On macOS (`__APPLE__`), `getrusage(RUSAGE_SELF, &usage)` reports `ru_maxrss` in bytes rather than kilobytes (KiB) as on Linux. Previously, `GetPeakRSSBytes()` unconditionally multiplied `usage.ru_maxrss` by 1024, overreporting peak RSS usage by 1024x on macOS and causing FuzzTest targets to abort immediately when a non-zero RSS limit was configured. Return `usage.ru_maxrss` directly on macOS in `GetPeakRSSBytes()` so watchdog RSS limit checks compare accurate byte counts across platforms. PiperOrigin-RevId: 998805274
diff --git a/fuzztest/internal/runtime.cc b/fuzztest/internal/runtime.cc index 2eb4f28..5df7ea7 100644 --- a/fuzztest/internal/runtime.cc +++ b/fuzztest/internal/runtime.cc
@@ -436,9 +436,14 @@ #else struct rusage usage = {}; if (getrusage(RUSAGE_SELF, &usage) != 0) return 0; - // On Linux, ru_maxrss is in KiB +#ifdef __APPLE__ + // On MacOS, ru_maxrss is in bytes. + return usage.ru_maxrss; +#else + // On Linux, ru_maxrss is in KiB. return usage.ru_maxrss * 1024; #endif +#endif } void Runtime::CheckWatchdogLimits() {