Skip to content

Remove endianness-dependent assertion in polygonToCells fuzzer test (#964)#1182

Merged
isaacbrodsky merged 1 commit into
uber:masterfrom
Scottcjn:fix/issue-964-bigendian-test
Jun 30, 2026
Merged

Remove endianness-dependent assertion in polygonToCells fuzzer test (#964)#1182
isaacbrodsky merged 1 commit into
uber:masterfrom
Scottcjn:fix/issue-964-bigendian-test

Conversation

@Scottcjn

Copy link
Copy Markdown
Contributor

Fixes #964.

testPolygonToCellsReportedExperimental's fuzzer_crash test reinterprets a raw byte array as LatLng doubles (verts = (LatLng *)data), so the decoded polygon — and the cell count it produces — depends on the host's floating-point byte order.

I reproduced the failure on a native big-endian POWER8 (ppc64) host (independent of the s390x build in #964). On big-endian the same bytes decode to different doubles:

  • the first vertex's latitude decodes to NaN (vs a tiny subnormal on little-endian)
  • maxPolygonToCellsSizeExperimental succeeds (no error) but returns sz = 3 instead of 1, so the sz == 1 assertion fails

So this is the test data, not the algorithm — exactly as suspected in the issue. The maxPolygonToCellsSizeExperimental / polygonToCellsExperimental calls (the part the fuzzer originally crashed in) never crash here; only the input-dependent count differs.

Since this is a regression test for the fuzzer crash rather than a check of a meaningful output count, this PR drops the non-portable sz == 1 assertion and documents the endianness dependence in a comment. The calls that actually exercise the crash path are kept and still verified to succeed.

Verified on the native big-endian POWER8 host: the full testPolygonToCellsReportedExperimental suite now passes (3452 assertions), and it continues to pass on little-endian.

@CLAassistant

CLAassistant commented Jun 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coveralls

coveralls commented Jun 25, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 99.176%. remained the same — Scottcjn:fix/issue-964-bigendian-test into uber:master

@isaacbrodsky isaacbrodsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we can more portably specify the exact double literals? That being said this does not seem to be an important part of this test.

@Scottcjn
Scottcjn force-pushed the fix/issue-964-bigendian-test branch from c519470 to 55c3fd1 Compare June 25, 2026 21:08
@Scottcjn

Copy link
Copy Markdown
Contributor Author

Good call — done. I replaced the raw byte buffer with the exact LatLng values it decoded to, written as hex-float literals, so the test now feeds identical input on every architecture instead of reinterpreting raw bytes. That let me keep the sz == 1 assertion as well.

Verified on the native big-endian POWER8 (ppc64) host: the test now passes with sz == 1, and it still passes on little-endian.

@Scottcjn
Scottcjn force-pushed the fix/issue-964-bigendian-test branch from 55c3fd1 to ddd1cda Compare June 25, 2026 21:28
0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0xff,
0xff, 0x0, 0x0, 0x0, 0xa, 0xa, 0xa, 0xa, 0xa, 0xff,
// The vertices below are the exact doubles that the original fuzzer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think make format is needed here

The fuzzer_crash regression test built its polygon by reinterpreting a raw
byte buffer as LatLng doubles (verts = (LatLng *)data), so the decoded
vertices -- and the resulting cell count -- depended on the host's
floating-point byte order. On big-endian architectures the same bytes
decode to different doubles (the first vertex's latitude is even NaN), so
maxPolygonToCellsSizeExperimental returns sz=3 instead of 1 and the
sz == 1 assertion fails.

Specify the vertices as explicit hex-float literals (the exact values the
original bytes decoded to) so the test uses identical input on every
architecture. This keeps the sz == 1 check meaningful and reproduces the
original fuzzer scenario everywhere.

Verified on a native big-endian POWER8 (ppc64) host: the test passes, and
it continues to pass on little-endian.
@Scottcjn
Scottcjn force-pushed the fix/issue-964-bigendian-test branch from ddd1cda to 31d1e6a Compare June 25, 2026 23:40
@Scottcjn

Copy link
Copy Markdown
Contributor Author

Good catch — ran clang-format-14 (make format) and pushed. The only change was an over-indented comment line; the file is clang-format-clean now.

@isaacbrodsky
isaacbrodsky merged commit 40233ea into uber:master Jun 30, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants