Repository navigation
Fix pending output corruption when changing file buffers - #3673
Merged
Merged
Conversation
fhgffy
marked this pull request as ready for review
October 3, 2026 23:51
Owner
|
Thanks @fhgffy |
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.
Changing a file sink from a 64 KiB buffer to 128 KiB while log output is pending can corrupt the previously written message. The original reproducer produced the expected 29 bytes, but their contents differed.
file_helper::set_buffer_size()resizes or releases storage that the openFILEstill uses, and callssetvbufafter I/O.Flush the pending output and reuse the existing non-truncating reopen path so the new buffer is configured before I/O. Assigning the same size is a no-op. After a size change, the rotating sink flushes callback output and refreshes its size estimate.
A size change now reopens the current pathname in append mode and invokes the existing close/open handlers. It uses the existing flush/reopen exception paths; callers must handle reconfiguration failures. This also avoids relying on runtime-specific behavior for repeated
setvbufcalls (C11 draft, section 7.21.5.6).Validation on Windows, MinGW GCC 15.1.0, C++11 Debug, with warnings treated as errors:
Linux/macOS, MSVC, wchar configurations, C++20
std::format, and sanitizers have not been run locally.