Skip to content

Commit

Permalink
RCORE-2234 Crash in dart due to debug output when app is being torn d…
Browse files Browse the repository at this point in the history
…own (#7985)

* Updated stderrlogger to use a mutex shared_ptr instead of a static
* Removed additional Logger static defines
* Updates from review - removed StderrLogger mutex - reverted some changes
* Reverted unnecessary changes, using global pointer mutex reference
* Removed StderrLogger local mutex reference
  • Loading branch information
Michael Wilkerson-Barker authored Aug 22, 2024
1 parent 67f0fa2 commit 2424fde
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Using an empty KeyPath in C API would result in no filtering being done ([#7805](https://github.com/realm/realm-core/issues/7805), since 13.24.0)
* Filtering notifications with backlink columns as last element could sometimes give wrong results ([#7530](https://github.com/realm/realm-core/issues/7530), since 11.1.0)
* Fix crash during client app shutdown when Logger log level is set higher than Info. ([#7969](https://github.com/realm/realm-core/issues/7969), since v13.23.3)

### Breaking changes
* None.
Expand Down
4 changes: 2 additions & 2 deletions src/realm/util/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace realm::util {

namespace {
auto& s_logger_mutex = *new std::mutex;
auto& s_stderr_logger_mutex = *new std::mutex;
std::shared_ptr<util::Logger> s_default_logger;
} // anonymous namespace

Expand Down Expand Up @@ -177,8 +178,7 @@ const std::string_view Logger::level_to_string(Level level) noexcept

void StderrLogger::do_log(const LogCategory& cat, Level level, const std::string& message)
{
static Mutex mutex;
LockGuard l(mutex);
std::lock_guard l(s_stderr_logger_mutex);
// std::cerr is unbuffered, so no need to flush
std::cerr << cat.get_name() << " - " << get_level_prefix(level) << message << '\n'; // Throws
}
Expand Down

0 comments on commit 2424fde

Please sign in to comment.