[logger] Fix Kernel GP seen for any short-lived *syncd process#444
Merged
vaibhavhd merged 3 commits intosonic-net:masterfrom Jan 12, 2021
Merged
[logger] Fix Kernel GP seen for any short-lived *syncd process#444vaibhavhd merged 3 commits intosonic-net:masterfrom
vaibhavhd merged 3 commits intosonic-net:masterfrom
Conversation
… thread_local for detached thread
qiluo-msft
reviewed
Jan 12, 2021
common/logger.h
Outdated
| std::atomic<Output> m_output = { SWSS_SYSLOG }; | ||
| std::unique_ptr<std::thread> m_settingThread; | ||
| std::mutex m_mutex; | ||
| bool terminateSettingThread = false; |
Contributor
Author
There was a problem hiding this comment.
Updated to volatile
qiluo-msft
approved these changes
Jan 12, 2021
Contributor
|
In the title, could you talk with the context of logger? |
yxieca
approved these changes
Jan 12, 2021
4 tasks
lguohan
pushed a commit
to sonic-net/sonic-buildimage
that referenced
this pull request
Jan 13, 2021
…ction error fix (#6436) To include Kernel GP fault seen in *syncd processes: sonic-net/sonic-swss-common#444
lguohan
pushed a commit
to sonic-net/sonic-buildimage
that referenced
this pull request
Jan 15, 2021
…ction error fix (#6436) To include Kernel GP fault seen in *syncd processes: sonic-net/sonic-swss-common#444
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.
Fixes: sonic-net/sonic-buildimage#6103
This PR is to fix the Kernel GP errors that are seen in any short-lived process within swss.
As part of *syncd initialization,
Logger::linkToDbNativefunction is called. This call starts aSettingThreadin the background.When the main *syncd process terminates the destructor
Logger::~Loggersimply detaches theSettingThread. This leads to the detached thread's continued exection in the background.At the same time, the exiting main process deletes the static variables that were in its scope.
Fault is hit when the detached thread (still executing in the infinite loop) tries to access these freed up variables.
This issue is easily reproducible when these *syncd process are short lived (and the detached
SettingThreadis still executing). Below are the examples by simply executing thehelpoption:Sample 1 : Orchagent core and Kernel GP:Sample 2 : Gearsyncd core and Kernel GP:Sample 3 : portsyncd core and Kernel GP:Fix:
SettingThreadthread.