Skip to content

Fix record-index misuse in generic runtime conformance - #131

Merged
ip332 merged 1 commit into
mainfrom
fix/85-clang18-conformance
Nov 22, 2026
Merged

ip332 merged 1 commit into
mainfrom
fix/85-clang18-conformance

Conversation

@ip332

@ip332 ip332 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Closes #85

The generic conformance test passed Parent's BRF wire record ID to a QBS API that expects a zero-based record-table index. In the retained fixture, Parent has wire ID 1 but table index 2; table index 1 is Item, which has no field 11. The old test dereferenced the resulting empty std::optional<QbsFieldView>: undefined behavior, not a parser/fixture/lifetime defect or a Clang miscompile. GCC's passing result masked the invalid access.

The test now resolves field 11 through the validated parent view's existing field_metadata() API, checks metadata engagement, and retains the original EXPECT_FALSE(is_present(...)). It also verifies the absent value and pins the fixture's wrong-index negative control. Existing positive field assertions remain unchanged.

CI now explicitly executes the complete generic conformance binary and fixture check under Linux Clang 18 Debug, then ASan/UBSan with _GLIBCXX_ASSERTIONS. The Docker test image adds libclang-rt-18-dev because its previous Clang installation lacked sanitizer runtimes. No assertions are weakened, tests disabled, or diagnostics suppressed. No runtime/compiler API or behavior, fixture bytes, BRF/QBS/IR formats, record allocation, schema_id, gid format/algorithm or epochs change.

Reproduction and regression evidence

Unchanged baseline: afac21be0c39a8ca799582cca2ad02f37f1c7b70 (A6 squash merge). Ubuntu 24.04.4 LTS x86-64, Clang 18.1.3 (1ubuntu1), GCC 13.3.0, CMake 3.28.3, Protobuf 3.21.12, libstdc++ headers from GCC13 (runtime package 14.2.0). The initial local image is quarry-dev:latest, image ID fc38baf5e580. Installing compiler-rt in the disposable sanitizer lab upgraded glibc 2.39's package from ubuntu8.9 to ubuntu8.12; compiler/Protobuf/libstdc++ versions remained unchanged.

Original Debug command (inside the repository Docker environment at the baseline):

cmake -S . -B build/issue85-clang18 -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18
cmake --build build/issue85-clang18 --parallel 2 \
  --target generic_runtime_conformance_test generic_runtime_conformance_fixture_generator
ctest --test-dir build/issue85-clang18 --output-on-failure \
  -R '^generic_runtime_conformance_(test|fixture_check)$'
Configuration Before Corrected maintained source
Clang18 Debug, original configuration Exact reported ValidFixture actual true / expected false; other 5 cases and fixture check pass 6/6 conformance cases and fixture check pass (2/2 CTests)
GCC13 Debug, same fixture 2/2 CTests pass, masking test UB 2/2 CTests pass
Clang18 Debug + ASan/UBSan + checked libstdc++ Aborts at optional:479: this->_M_is_engaged(); fixture check passes 2/2 CTests pass without sanitizer diagnostics

A checked diagnostic probe reports the three table-index/wire-ID pairs and confirms actual field 11 is absent while field 0 is present. A wrong-lookup mutation of the guarded correction also fails on GCC at the intended absent_field.has_value() assertion (normal test exit 1), proving detection no longer depends on Clang's empty-optional storage contents.

Retained fixture SHA-256:

  • QBS: 043d9b3ad9f6bd8c0e7c58228fe3a2a1344fd1b7873613d7f1f11d733ab44fc4
  • BRF: d3c570f6e2043032d9c4367e8dc3e6cba35f78516f03c6928dd19a1bfe9424d6

Final head: 87d7f78a20ca1095c78f1c10a66ede8d9acee6c2.

scripts/quarry-validate validate HEAD passed 73/73 native CTests (622.31 s; total validation 652.6 s, two build/test slots) on this exact head. Receipt fingerprint: b7f585657bf5daa66bdab10be82e525d12d64a6102147de836fa5292a6dbbd39. Configured clang-format/YAML/whitespace hooks and git diff --check passed. Delivery uses scripts/quarry-validate push with hooks enabled. Native SDK/duplicate-library warnings are existing host-toolchain messages; no production sources changed.

Exact-head CI passed all applicable jobs: Linux GCC Build and test (73/73 CTests, 384.91 s), clang-tidy, Coverage baseline (68/68 CTests, 305.34 s, baseline guard passed), and Cortex-M Cross Build. Benchmarks retained its existing PR-policy skip. The Linux Clang 18 interoperability matrix passed; the new generic conformance step passed 2/2 CTests in Debug and 2/2 under ASan/UBSan with checked libstdc++, without sanitizer diagnostics. GCC LTO validation also passed. Earlier A6 CI is not substituted for this fix.

A6 completion is separate: PR #128 squash-merged as afac21be0c39a8ca799582cca2ad02f37f1c7b70, #104 automatically closed, local main synchronized, and all five post-merge CI jobs passed before repository changes began.

#88 is intentionally not implemented; it must follow independent review and merge of this PR. #90/#119 and follow-ups #129/#130 remain unchanged. No release/tag publication, #105 execution or Stage B work. Do not merge automatically.

@ip332 ip332 added this to the v0.1.31-rc.1 milestone Nov 22, 2026 — with ChatGPT Codex Connector
@ip332 ip332 added bug Something isn't working area: tests Test suites, fixtures and conformance matrices labels Nov 22, 2026 — with ChatGPT Codex Connector
@ip332
ip332 marked this pull request as ready for review November 22, 2026 05:09

@ip332 ip332 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent technical review — GO / approved for squash merge at exact head 87d7f78a20ca1095c78f1c10a66ede8d9acee6c2.

Inspected all three changed files and the tested runtime metadata API. Root cause verified: the old ValidFixture test passed a wire record_id to a QBS find_field overload that expects a record-table index and dereferenced a disengaged std::optional. The fix resolves field 11 through validated parent field_metadata, asserts engagement before dereference, preserves the absent-field assertion and adds wrong-index and absence controls. Production sources, wire fixtures, public API/epochs and identity formats are unchanged. CI now runs Clang 18 Debug plus ASan/UBSan with checked libstdc++ and installs the required compiler-rt package.

Exact-head workflow 44986124280 completed successfully: Linux build/test (73/73), coverage (68/68), clang-tidy, Cortex-M; Clang18 Debug and ASan/UBSan each pass 2/2 conformance CTests. Benchmarks skipped by established PR policy. No merge-blocking technical defect found.

Administrative note: GitHub currently reports issue #85 as closed while PR #131 is still open. Verify issue closure is tied to delivered code only after merge, and confirm post-merge CI. #88 remains a separate release gate. No merge or publication performed. This is a technical-review COMMENT, not formal GitHub APPROVE, because the connected GitHub account is the PR author.

@ip332
ip332 merged commit 33b033e into main Nov 22, 2026
5 checks passed
@ip332
ip332 deleted the fix/85-clang18-conformance branch November 22, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suites, fixtures and conformance matrices bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generic_runtime_conformance_test ValidFixture fails with Clang 18 on Linux

1 participant