8000 Bug fixes for directed edge by isaacbrodsky · Pull Request #559 · uber/h3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bug fixes for directed edge #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jan 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0277ce5
Add LLVM fuzzer harness
Dec 22, 2021
1c8ec2e
Add AFL++ test case generator
Dec 22, 2021
b89c76b
Fuzz more gridDisk functions
Dec 22, 2021
79d2e2c
add fuzzerH3SetToLinkedGeo
Dec 22, 2021
a28a807
Add more fuzzers
Dec 22, 2021
9445cbb
Additional fuzzers
Dec 22, 2021
f971dcf
add fuzzerVertexes
Dec 22, 2021
e0c8841
Add test-fuzzer script
Dec 22, 2021
007b7c3
Fix linux build
Dec 22, 2021
02abb99
Fix fuzzerIndexIO
Dec 22, 2021
caedc90
test-fuzzer use subshell for ls
isaacbrodsky Dec 22, 2021
de5a2c3
Update test-fuzzer again
isaacbrodsky Dec 22, 2021
8bbc36a
Fix test-fuzzer again
isaacbrodsky Dec 22, 2021
021c994
fuzzerCompact
Dec 23, 2021
2195863
Update readme
Dec 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/apps/fuzzers/fuzzerGridDisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef struct {
int64_t k;
} inputArgs;

const int64_t MAX_GRID_DISK_SIZE = 0x1000000000;
const int64_t MAX_GRID_DISK_SIZE = 0x10000000;

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < sizeof(inputArgs)) {
Expand Down
15 changes: 15 additions & 0 deletions src/apps/testapps/testDirectedEdge.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ SUITE(directedEdge) {
"getting the origin from a null index returns error");
}

TEST(getDirectedEdgeOriginBadInput) {
H3Index sf;
t_assertSuccess(H3_EXPORT(latLngToCell)(&sfGeo, 9, &sf));
H3Index ring[7] = {0};
t_assertSuccess(H3_EXPORT(gridRingUnsafe)(sf, 1, ring));
H3Index sf2 = ring[0];

H3Index edge;
t_assertSuccess(H3_EXPORT(cellsToDirectedEdge)(sf, sf2, &edge));
H3_SET_RESERVED_BITS(edge, INVALID_DIGIT);
H3Index out;
t_assert(H3_EXPORT(getDirectedEdgeDestination)(edge, &out) == E_FAILED,
"Invalid directed edge fails");
}

TEST(getDirectedEdgeDestination) {
H3Index hexagon = 0x891ea6d6533ffff;

Expand Down
13 changes: 13 additions & 0 deletions src/apps/testapps/testGridDisk.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,19 @@ SUITE(gridDisk) {
t_assert(out == origin, "Moving to self goes to self");
}

TEST(h3NeighborRotations_invalid) {
// This is undefined behavior, but it's helpful for it to make sense.
H3Index origin = 0x811d7ffffffffffL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything special about this particular H3 index?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - I just needed a known good index as I wanted the only rotations to be under test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my info, is there any difference between indexes with the L suffix or without? Should we be consistent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All valid H3 indexes would only be valid integers as 64 bit, so no I don't believe so.

int rotations = 0;
H3Index out;
t_assert(h3NeighborRotations(origin, -1, &rotations, &out) == E_FAILED,
"Invalid direction fails (-1)");
t_assert(h3NeighborRotations(origin, 7, &rotations, &out) == E_FAILED,
"Invalid direction fails (7)");
t_assert(h3NeighborRotations(origin, 100, &rotations, &out) == E_FAILED,
"Invalid direction fails (100)");
}

TEST(cwOffsetPent) {
// Try to find a case where h3NeighborRotations would not pass the
// cwOffsetPent check, and would hit a line marked as unreachable.
Expand Down
4 changes: 3 additions & 1 deletion src/h3lib/lib/algos.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ H3Error h3NeighborRotations(H3Index origin, Direction dir, int *rotations,
H3Index *out) {
H3Index current = origin;

if (dir < CENTER_DIGIT || dir >= INVALID_DIGIT) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my info, what does CENTER_DIGIT even do? Returns the current index?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is my expectation

return E_FAILED;
}
for (int i = 0; i < *rotations; i++) {
dir = _rotate60ccw(dir);
}
Expand All @@ -352,7 +355,6 @@ H3Error h3NeighborRotations(H3Index origin, Direction dir, int *rotations,
int r = H3_GET_RESOLUTION(current) - 1;
while (true) {
if (r == -1) {
// TODO: dir may be invalid here (verify via fuzzerDirectedEdge)
H3_SET_BASE_CELL(current, baseCellNeighbors[oldBaseCell][dir]);
newRotations = baseCellNeighbor60CCWRots[oldBaseCell][dir];

Expand Down
0