Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc @@ -94,10 +94,12 @@ } static void setlim(int res, rlim_t lim) { - // The following magic is to prevent clang from replacing it with memset. - volatile struct rlimit rlim; + struct rlimit rlim; + if (getrlimit(res, const_cast(&rlim))) { + Report("ERROR: %s getrlimit() failed %d\n", SanitizerToolName, errno); + Die(); + } rlim.rlim_cur = lim; - rlim.rlim_max = lim; if (setrlimit(res, const_cast(&rlim))) { Report("ERROR: %s setrlimit() failed %d\n", SanitizerToolName, errno); Die(); Index: compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc =================================================================== --- compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc +++ compiler-rt/trunk/test/sanitizer_common/TestCases/corelimit.cc @@ -10,7 +10,7 @@ getrlimit(RLIMIT_CORE, &lim_core); void *p; if (sizeof(p) == 8) { - assert(0 == lim_core.rlim_max); + assert(0 == lim_core.rlim_cur); } return 0; }