Skip to content

Fix XmLog segfault in pybind11 shared libraries#112

Merged
wdolinar merged 1 commit intomasterfrom
fix/xmlog-stdio-for-pybind
Mar 24, 2026
Merged

Fix XmLog segfault in pybind11 shared libraries#112
wdolinar merged 1 commit intomasterfrom
fix/xmlog-stdio-for-pybind

Conversation

@wdolinar
Copy link
Copy Markdown
Member

Summary

  • Replace std::ofstream with FILE*/fprintf in XmLog to avoid segfaults caused by NULL locale facets (codecvt vtable) when the .so is statically linked against libstdc++ and loaded into a Python process
  • Replace std::put_time with std::strftime and the operator<< overload with a plain iSeverityStr() function to eliminate all remaining iostream/locale dependencies in the log writer

Test plan

  • Build and run xmscore test suite (runner)
  • Build pybind11 shared library and verify import xmscore no longer segfaults in Python
  • Verify log file output format is unchanged

std::ofstream locale facets (codecvt vtable) are NULL when the .so is
statically linked against libstdc++ and loaded into a Python process.
Replace std::ofstream with FILE*/fprintf and std::put_time with
std::strftime so the log writer no longer depends on locale machinery.
@wdolinar wdolinar merged commit 277d73c into master Mar 24, 2026
14 checks passed
@wdolinar wdolinar deleted the fix/xmlog-stdio-for-pybind branch March 24, 2026 20:14
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.

1 participant