-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If the tree contained a leaf under a node that had matching prefix to the lowerbound search key, but which was smaller then we hit the "prefix smaller" case which incorrectly returned an empty set of edges to explore when it should've returned the larger set of edges from the parent(s). Reproducer from fuzz test for the bug: node4[[0 0 0 0 0 1]]:(0xc000176910) leaf[[18 226]]: [0 0 0 0 0 1 18 226] -> 70370(0xc00007e4b0) node48[[19]]:(0xc00014f6c0) leaf[[11]]: [0 0 0 0 0 1 19 11] -> 70411(0xc00007e6e0) leaf[[12]]: [0 0 0 0 0 1 19 12] -> 70412(0xc00007e730) leaf[[13]]: [0 0 0 0 0 1 19 13] -> 70413(0xc00007e910) leaf[[14]]: [0 0 0 0 0 1 19 14] -> 70414(0xc00007eaa0) Search key was [... 0 1 18 240 ], which lead the lowerbound search to "leaf[[18 226]]" and to the false conclusion that there is nothing in the tree above the search key, when in fact it should've returned "node48[[19]]" as the edge to explore. Added regression test for this exact reproducer, and edge case tests for lowerbound() and checked that all cases were covered. Removed the "len(key) == 0" branch as that is never taken since we compare to the prefix with "min(len(key), len(prefix)", so if len(key) < len(prefix) we always end up in the "-1" case instead. For ease of debugging in future, PrintTree() now uses %x instead of %v to print keys in hex.
- Loading branch information
Showing
4 changed files
with
181 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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