Skip to content

Native host test FormatUtilsTest.TestDetectFormatVersion fails on host g++ (quarantined from CI) #80

@AsafMah

Description

@AsafMah

Surfaced by the new native host test harness (#78) — the first thing it caught.

Symptom

FormatUtilsTest.TestDetectFormatVersion fails on the host build (Linux, g++ 13, -O2):

format_utils_test.cpp:60: Expected equality of these values:
  FormatUtils::VERSION_2  (2)
  FormatUtils::detectFormatVersion(...)  (-1 == UNKNOWN_VERSION)

The test builds a 12-byte big-endian header [9B C1 3A FE | 00 02 | 00 00 | 00 00 00 00] and expects detectFormatVersion to report VERSION_2; on host it reports UNKNOWN.

What was ruled out

  • Size guard: DICTIONARY_MINIMUM_SIZE = 12, buffer is exactly 12 → guard passes.
  • readUint32 signed-shift UB: suspected (uint8_t promotes to int, 0x9B << 24 overflows signed int = UB), but an isolated g++ -O2 repro shows both the int-promoted and uint32_t-cast forms produce 0x9BC13AFE. So the magic read works in isolation.
  • Static analysis of the full path (readUint32switchgetFormatVersion(readUint16(...,4))) looks correct.

Root cause not yet isolated — likely a host/optimization or ReadOnlyByteArrayView/AK_FORCE_INLINE interaction specific to the host toolchain. The engine works correctly on-device (the app ships and reads dictionaries fine); this is a host-build-only discrepancy in a test that had never been run in CI.

Action

  • Quarantined from the A3d: Native gesture-recognition replay harness + run native tests in CI #78 CI gate (ctest -E 'FormatUtilsTest.TestDetectFormatVersion') so the other 65 native tests gate as a blocking net.
  • This issue tracks isolating the real cause (and, if it is the readUint32 signed-shift UB after all, hardening it with explicit uint32_t casts — provably identical on-device, removes UB).

Low priority (no on-device impact), but a good demonstration that the harness reaches code the JVM tests cannot.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions