Skip to content

Commit 1e38d40

Browse files
committed
Always log to stderr before making any system calls (which might not
succeed).
1 parent cfbf82e commit 1e38d40

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libcxx/src/log_error.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
namespace {
2525

2626
void log_security_failure(const char* message) noexcept {
27+
// Always log the message to `stderr` in case the platform-specific system calls fail.
28+
fprintf(stderr, "%s", message);
29+
2730
// On Apple platforms, use the `os_fault_with_payload` OS function that simulates a crash.
2831
#if defined(__APPLE__) && __has_include(<os/reason_private.h>)
2932
os_fault_with_payload(
@@ -42,9 +45,6 @@ void log_security_failure(const char* message) noexcept {
4245
openlog("libc++", 0, 0);
4346
syslog(LOG_CRIT, "%s", message);
4447
closelog();
45-
46-
#else
47-
fprintf(stderr, "%s", message);
4848
#endif
4949
}
5050

0 commit comments

Comments
 (0)