Repository navigation
Fix crash on async logs flushed after the destination changed - #96
Merged
Merged
Conversation
InitializeLogFileHandle() also succeeds without opening anything when the destination no longer logs to a file, and Log2File() only looked at the return value: an async log that was still in the queue when a later InitLogging() moved the destination away from the file was written through a null FILE* and took the whole process down. The clang-unittest CI hit it through LogRotationTest::TearDown(), which restores the default destination: on builds with the cpu profiler enabled, LoggingTest.performance leaves millions of logs in the queue and the background thread keeps flushing them long after the test is over. The write is skipped when there is no handle to write through, the way MaybeRotateLogFileUnlocked() already checks. The queue draining behind the tests has a second effect: those logs go to whichever file is current, rotating it from under the assertions of the rotation tests that follow. LogRotationTest::SetUp() now drains the queue into the temp file first, with rotation on to bound the disk usage, and waits until the file stops growing, which costs a single stat() poll when the queue is already idle. A regression test reproduces the crash sequence (async backlog, CloseLogFile(), destination change) and the fixture now also saves and restores --async_log_in_background_always.
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.
No description provided.