fix: thread-safety fixes for log_version_info and flush_logs, Linux locale init#336
Open
SukiSunYuhang wants to merge 4 commits into
Open
fix: thread-safety fixes for log_version_info and flush_logs, Linux locale init#336SukiSunYuhang wants to merge 4 commits into
SukiSunYuhang wants to merge 4 commits into
Conversation
…ocale init - log_version_info: cache OS description with std::call_once to prevent wxGetLinuxDistributionInfo/wxGetOsDescription from being called on background threads (GTK/wx APIs are not thread-safe on Linux). Previously, generic_exception_handle -> OnExceptionInMainLoop could trigger these calls from BackgroundSlicingProcess worker threads, causing crashes when opening network test dialog on Linux. - flush_logs: add mutex to protect g_log_sink shared_ptr access against concurrent flush calls from multiple threads. - on_init_inner: call std::setlocale(LC_ALL, "") on Linux early in startup to fix garbled Chinese text and GTK file dialog crashes. - NetworkTestDialog::start_all_job: add atomic flag to prevent re-entrant test launches from rapid button clicks.
…tLocalArea, getLanguage All four functions had empty #else (Linux) branches, causing them to always return empty strings on Linux. Added get_linux_config_dir() helper that resolves $XDG_CONFIG_HOME/Snapmaker_Orca or ~/.config/Snapmaker_Orca, consistent with how data_dir() is determined on Linux.
… detach and let the m_closing checkpoint handle the rest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Thread-safety for log_version_info: Cache OS description with std::call_once to prevent wxGetLinuxDistributionInfo/wxGetOsDescription from being called on background threads. These wx APIs are not thread-safe on Linux (GTK), and were being triggered via generic_exception_handle → OnExceptionInMainLoop from BackgroundSlicingProcess worker threads, causing crashes when using the network test dialog.
Mutex for flush_logs: Add a static mutex to protect the global g_log_sink shared_ptr access against concurrent flush calls from multiple threads.
Linux locale initialization: Call std::setlocale(LC_ALL, "") early in on_init_inner to fix garbled Chinese text and GTK file dialog crashes on Linux.
Anti-reentrancy for network test: Add atomic flag to NetworkTestDialog::start_all_job to prevent re-entrant test launches from rapid button clicks.
Files changed
src/libslic3r/utils.cpp — add mutex to flush_logs()
src/slic3r/GUI/GUI_App.cpp — cache OS info in log_version_info() + Linux locale init
src/slic3r/GUI/NetworkTestDialog.cpp — anti-reentrancy in start_all_job()
src/slic3r/GUI/NetworkTestDialog.hpp — new m_all_testing atomic flag