diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp index 7ef499ce07b13331e8cb0142df288d4e0f37bc1a..dd791d190c2c08c23a2fcc53739b663ba029cbcf 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp @@ -21,6 +21,8 @@ #include "sanitizer_file.h" # include "sanitizer_interface_internal.h" +extern "C" SANITIZER_WEAK_ATTRIBUTE int musl_log(const char *fmt, ...); + namespace __sanitizer { void CatastrophicErrorWrite(const char *buffer, uptr length) { @@ -71,7 +73,14 @@ void ReportFile::ReopenIfNecessary() { char errmsg[100]; internal_snprintf(errmsg, sizeof(errmsg), " (reason: %d)", err); WriteToFile(kStderrFd, errmsg, internal_strlen(errmsg)); +#if SANITIZER_OHOS // OHOS_LOCAL + if (&musl_log) { + musl_log("%s %s %s\n", ErrorMsgPrefix, full_path, errmsg); + } + internal__exit(common_flags()->exitcode); +#else Die(); +#endif } fd_pid = pid; }