Skip to content

fix(logging): no-op Logger::Log when not initialized - #747

Merged
JeanPhilippeKernel merged 1 commit into
JeanPhilippeKernel:developfrom
BetterAndBetterII:fix/logger-log-uninit-guard
Sep 4, 2026
Merged

fix(logging): no-op Logger::Log when not initialized#747
JeanPhilippeKernel merged 1 commit into
JeanPhilippeKernel:developfrom
BetterAndBetterII:fix/logger-log-uninit-guard

Conversation

@BetterAndBetterII

Copy link
Copy Markdown
Contributor

Summary

Logger::Log indexed the ring buffer with fetch_add(...) % s_log_message_rb.size() without checking initialization. Before Initialize() the capacity is zero (modulo-by-zero / SIGFPE). After Dispose() the same path can recurse through assert macros back into Log until the stack overflows.

Return immediately when !IsInitialized(). IsInitialized() already exists; this just uses it at the top of Log.

Test plan

  • LoggerUninitialized.LogBeforeInitializeDoesNotCrash — was RED (SIGFPE), now GREEN
  • LoggerTest.LogAfterDisposeDoesNotCrash — GREEN
  • Existing LoggerTest.* still pass (15/15 in the isolated Logger binary)
ZEngineTests --gtest_filter='LoggerUninitialized.*:LoggerTest.*'

Fixes #746

Calling Log before Initialize (or after Dispose) divided by a zero-sized
ring buffer and could recurse through assert macros. Guard with
IsInitialized() and cover before-init / after-dispose paths.

Fixes JeanPhilippeKernel#746
@JeanPhilippeKernel JeanPhilippeKernel added this to the Stable Core (1.0.0) milestone Sep 4, 2026
@JeanPhilippeKernel JeanPhilippeKernel added enhancement New feature or request area-linux Work on Linux system area-window Work on Window system area-macOS Work on macOS system labels Sep 4, 2026

@JeanPhilippeKernel JeanPhilippeKernel left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @BetterAndBetterII !!

@JeanPhilippeKernel
JeanPhilippeKernel merged commit 7b0d94b into JeanPhilippeKernel:develop Sep 4, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-linux Work on Linux system area-macOS Work on macOS system area-window Work on Window system enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Logger::Log crashes via infinite recursion when called before Logger::Initialize

2 participants