Skip to content

Make Logger safe from static initialization order fiasco (NGWPC-7168) - #11

Merged
idtodd merged 2 commits into
developmentfrom
PhilMiller-7186-logging
Aug 28, 2025
Merged

Make Logger safe from static initialization order fiasco (NGWPC-7168)#11
idtodd merged 2 commits into
developmentfrom
PhilMiller-7186-logging

Conversation

@PhilMiller

@PhilMiller PhilMiller commented Aug 26, 2025

Copy link
Copy Markdown

In dynamic initialization of a global static instance of InterpreterUtil, there was a call to LOG that happened to be running before the dynamic initialization of the class-static members of Logger. This led to invalid memory accesses and hence crashes. These crashes were a symptom of C++ Static Initialization Order Fiasco.

Changes

  • Logger: Make most member variables instance members rather than static, and introduce a GetLogger() function to contain a static pointer to a simple singleton instance that can be initialized safely

Testing

  1. CI Pipeline
  2. Private modification of test_bmi_python to trigger the failure case regardless of a NumPy version mismatch

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

@PhilMiller
PhilMiller marked this pull request as ready for review August 26, 2025 04:55
@PhilMiller PhilMiller changed the title Rough take on making Logger safe from static initialization order fiasco Make Logger safe from static initialization order fiasco Aug 26, 2025
@PhilMiller PhilMiller changed the title Make Logger safe from static initialization order fiasco Make Logger safe from static initialization order fiasco (NGWPC-7168) Aug 26, 2025
@idtodd
idtodd merged commit 0c54417 into development Aug 28, 2025
3 checks passed
@PhilMiller
PhilMiller deleted the PhilMiller-7186-logging branch August 29, 2025 18:27
zhengtaocui pushed a commit that referenced this pull request May 18, 2026
…sco (#11)

In dynamic initialization of a global static instance of InterpreterUtil, there was a call to LOG that happened to be running before the dynamic initialization of the class-static members of Logger. This led to invalid memory accesses and hence crashes. These crashes were a symptom of C++ Static Initialization Order Fiasco.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants