Skip to content

Fix crash on async logs flushed after the destination changed - #96

Merged
Sherlock0203 merged 1 commit into
LinQuickDev:logfrom
Sherlock0203:log
Oct 28, 2026
Merged

Sherlock0203 merged 1 commit into
LinQuickDev:logfrom
Sherlock0203:log

Conversation

@Sherlock0203

Copy link
Copy Markdown

No description provided.

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.
@Sherlock0203
Sherlock0203 merged commit 76549fe into LinQuickDev:log Oct 28, 2026
1 check passed
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