From 8e81caf01aef11d6bc6ec2c3c49135fdb2b59b8b Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Mon, 31 Mar 2014 17:18:06 -0700 Subject: [PATCH] Fix Autoroll logger Summary: If auto roll logger can't create a new LOG file on roll (if, for example, somebody deletes rocksdb directory while rocksdb is running, khm), we'll try to call Logv on invalid address and get a SIGSEGV. This diff will fix the issue Here's the paste of the stack trace: https://phabricator.fb.com/P8276386 (fb-only) Test Plan: make check is fine, although not really testing error condition Reviewers: haobo, ljin, yhchiang Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D17367 --- util/auto_roll_logger.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/auto_roll_logger.cc b/util/auto_roll_logger.cc index 0a00a586e..067404340 100644 --- a/util/auto_roll_logger.cc +++ b/util/auto_roll_logger.cc @@ -47,7 +47,11 @@ void AutoRollLogger::Logv(const char* format, va_list ap) { if ((kLogFileTimeToRoll > 0 && LogExpired()) || (kMaxLogFileSize > 0 && logger_->GetLogFileSize() >= kMaxLogFileSize)) { RollLogFile(); - ResetLogger(); + Status s = ResetLogger(); + if (!s.ok()) { + // can't really log the error if creating a new LOG file failed + return; + } } // pin down the current logger_ instance before releasing the mutex.