Repository navigation
view: fixes from the review of the Fluent Bit upgrade - #111
Merged
Merged
Conversation
cfl_view_kvlist_load() with a NULL list returned -1 and left the view attached to the list it was loaded over, so a later commit applied the pending edits to that list. It now leaves the view empty and detached, like every other failed load. A variant in the allocator of the list moves into it on commit without a copy. A string or bytes payload it referenced, at any depth, could point at a key the same commit renames or at a pair it removes, and was read after the commit freed it. The commit now gives the variant its own copy of those payloads before it moves. The comment of cfl_view_modified_clear() no longer says the view reads as unmodified: the entries keep their edits and the source does not match the view. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Two new cases, and the reads in 'kvlist_read' and 'variants' no longer dereference a result that a failed check left NULL. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
A view can be materialized only when its backend has the callback for the source entries that are left. A cleared modified mark records that the edits were written elsewhere; it does not make the source match the view. The changelog says that cfl_kvlist_rename_s() compares bytes. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
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.
Summary
Fixes the six findings the automated review raised on the CFL code in fluent/fluent-bit#12881. Two are defects in map views, one is a test robustness item, three are documentation.
Code
cfl_view_kvlist_load()left the view attached. With aNULLlist the call returned -1 but kept the view on the list it was loaded over, so a later commit applied the pending edits to that list. It now leaves the view empty and detached, as the header already promised for a failed load.Tests
refused_load_detaches: stages a rename, attempts theNULLload, checks the commit fails and the list is unchanged.commit_owns_referenced_payloads: a string, and an array holding a string, bytes and a nested list, all referencing a renamed key or a removed pair; heap and arena. Without the fix it fails under ASan with a heap-use-after-free.kvlist_readandvariantsno longer dereference a result that a failed check leftNULL.Documentation
VIEW.md: a view can be materialized only when its backend has thematerializecallback for the source entries that are left.VIEW.mdandcfl_view.h: a cleared modified mark records that the edits were written elsewhere. It does not make the source match the view, so after a clearcfl_view_modified()alone must not decide a whole-map copy.CHANGELOG.md:cfl_kvlist_rename_s()compares bytes, while the default fetch ignores case.Behavior change
A referenced string or bytes payload inside a variant handed to a kvlist view is copied at commit, so the list owns it afterwards. Before, it stayed referenced when the variant and the list shared an allocator.
Testing
scripts/agent-verify.sh.