Repository navigation
Conversation
cfl_list_add_after() set next->prev to the anchor entry instead of the inserted one. Forward iteration still worked, but backward links were broken. When inserting after the tail, head->prev stayed on the old tail, so a later cfl_list_add() tail insert dropped the new entry from the list. Signed-off-by: Eduardo Silva <eduardo@calyptia.com>
Insert in the middle and after the tail, then verify the back links, a following tail insert, and forward and reverse iteration. Signed-off-by: Eduardo Silva <eduardo@calyptia.com>
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.
Problem
cfl_list_add_after()setsnext->prev = previnstead ofnext->prev = _new. Forward iteration still works, but the back link of the entry after the inserted one stays on the anchor.When the anchor is the tail,
head->prevkeeps pointing at the old tail. A latercfl_list_add()tail insert then links the new entry after the old tail and drops the entry thatcfl_list_add_after()inserted. Reverse iteration andcfl_list_entry_last()are also wrong.Fluent Bit hits this when restoring a removed kvlist pair after the last key, if a processor inserts at the tail afterwards.
processor_labelsalso callscfl_list_add_after().Fix
Point
next->prevat the inserted entry, matchingcfl_list_add_before()and__cfl_list_add().Tests
tests/list.cgets anadd_aftercase: it inserts in the middle and after the tail, then checks the back links, a followingcfl_list_add(), and forward and reverse iteration. The case fails without the fix and passes with it.Compatibility
No API or ABI change. Only the broken back link changes; callers that relied on forward iteration see the same order.