Skip to content

ggml-hrx: keep GCC 15 diagnostic false positives out of the deps -Werror - #237

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/gcc15-array-bounds-deps
Nov 8, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/gcc15-array-bounds-deps

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Building ggml-hrx from source (-DHRX_SOURCE_DIR=…, which is how this box builds it now that no hrx package is installed) fails on gcc 15.2.0, inside the ggml-hrx-deps ExternalProject. It fails three times over, each in code that is not HRX inference and not ours to rewrite (the AMD tree), so the fix belongs in our build glue.

Who this blocks: every lane that builds HRX from source rather than against a prebuilt package — on this box that is the
-DHRX_SOURCE_DIR=…/third_party/hrx-system form used by ~/lb/dsv41-{lid,merged,stack}-build.sh and the ~/wt/315-*
scripts (checked, not assumed). It is the same failure the kernel lane hit and worked around per-build; this puts the fix in
one place.

The three, classified honestly rather than lumped together

  1. runtime/src/iree/async/util/continuation.h:75 — -Werror=array-bounds, FALSE POSITIVE. In iree_async_continuation_chain_iterator_next, values[iterator->next_head_index - 1] indexes an unsigned iree_host_size_t that is pre-incremented in the loop body before the subscript, behind an early return that guarantees it is < count. So the index is 0..count-1 whenever it is evaluated: no negative index exists, and the increment cannot overflow. GCC's message shows the mechanism — it specialised the pointee to iree_async_operation_t *[1] at a count == 1 call site and warns about a hypothetical -1; it loses the pre-increment fact across the do-while when inlining.

  2. loom/.../aie2p/lower/transpose.c:366 — -Werror=stringop-overflow, FALSE POSITIVE. "writing 16 bytes into a region of size 15" at offset [113,128] of the 128-byte source_lanes. The fill writes source_lanes[lane_count .. padded_lane_count-1], and lane_count is bounded by 128 for every type the carrier table admits (vector_carrier.c: I1 ≤ 128, accumulator ≤ 2048/bit_count, ordinary ≤ 1024/bit_count), so the power-of-two padded_lane_count is ≤ 128 too. GCC vectorises the fill and cannot see an invariant established in another translation unit.

  3. loom/tooling/testbench/expectation.c:1112 — -Werror=format-overflow, NOT a false positive. It formats (int)name.size, name.data with %.*s, and an empty iree_string_view_t can carry data == NULL, so a NULL can reach %s. That is latent UB — in an error-message path of a testbench tool, in AMD's tree, which this fork must not modify. Demoting the promotion is the only place we can act on it, and it cannot affect a shipped path.

Change

ggml/src/ggml-hrx/CMakeLists.txt: when CMAKE_C_COMPILER_ID is GNU and VERSION_GREATER_EQUAL 15, append
-Wno-error=array-bounds -Wno-error=stringop-overflow -Wno-error=format-overflow (to both CMAKE_C_FLAGS and
CMAKE_CXX_FLAGS, preserving whatever the outer configure set) to the ggml-hrx-deps ExternalProject arguments.

Scope, verified in the generated build.ninja: the flags appear only in the ggml-hrx-deps configure command; the outer
build and every llama.cpp target keep -Werror. It is -Wno-error=, not -Wno-, so all three diagnostics still print. No
AMD tree is touched.

Proven

  1. Reproduced first, unmodified tree, hrx-system source at the pin 82804197b, gcc 15.2.0:
    continuation.h:75:38: error: array subscript -1 is outside array bounds of 'iree_async_operation_t *[1]' [-Werror=array-bounds=]
    (3 occurrences, rc=1) — then, with that demoted, the loom pair above, each from a fresh configure.
  2. Clean from-source build (fresh directory, IREE + loom + libhrx built from source, not the prebuilt package) completes
    with llama-cli and test-backend-ops. Reconfigured once more without the outer probe flag and rebuilt, so the
    proof is the committed patch alone: rc=0, no errors.
  3. test-backend-ops -b HRX0 -o MUL_MAT on that build: FILL_TEST.

Building ggml-hrx from source (-DHRX_SOURCE_DIR, which is how this box builds it now that no hrx package is installed)
fails on gcc 15.2.0 inside the ggml-hrx-deps ExternalProject, three times over, each in code we do not ship and none of it
in HRX inference:

1. runtime/src/iree/async/util/continuation.h:75 -Werror=array-bounds. `values[iterator->next_head_index - 1]` indexes an
   unsigned iree_host_size_t that is pre-incremented in the loop body before the subscript, behind an early return that
   keeps it < count, so the index is 0..count-1 whenever it is evaluated. GCC 15 loses the ">= 1 after the pre-increment"
   fact across the do-while and warns about a hypothetical -1. False positive.

2. loom/.../aie2p/lower/transpose.c:366 -Werror=stringop-overflow ("writing 16 bytes into a region of size 15"). The
   power-of-two fill writes source_lanes[lane_count .. padded_lane_count-1] into a 128-byte array, and lane_count is
   bounded by 128 for every type the carrier table admits (vector_carrier.c: I1 <= 128, accumulator <= 2048/bit_count,
   ordinary <= 1024/bit_count), so padded_lane_count <= 128. GCC vectorises the fill and cannot see that cross-TU
   invariant. False positive.

3. loom/tooling/testbench/expectation.c:1112 -Werror=format-overflow ("%.*s directive argument is null"). This one is not a
   false positive: an empty iree_string_view can carry data == NULL, and that reaches %s. It is latent UB in an
   error-message path of a testbench tool, in AMD tree that this fork must not modify - so demoting the promotion here is
   the only place we can act on it, and it cannot affect a shipped path.

The suppression is scoped as tightly as the problem allows: only the deps build (the outer build and everything llama.cpp
compiles keep -Werror), only when the compiler is GNU and version >= 15, and -Wno-error= rather than -Wno- so every
diagnostic still prints in the log.

Proven: three errors reproduced first against the unmodified tree with hrx-system source at the pin; then a clean
from-source configure+build (IREE, loom, libhrx built from source in a fresh directory) completes with llama-cli and
test-backend-ops, and test-backend-ops -o MUL_MAT on HRX0 passes against the CPU reference.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

VERDICT: READY at 5ec9d7c43014a41a157d56703737ebfdda2e8c3d

The scoping claims are what matter here — a demoted warning that leaks into the outer build would be a way to hide real out-of-bounds bugs — and all three hold:

  • only the deps build: the flags are appended to GGML_HRX_CMAKE_ARGS, which is passed solely to ExternalProject_Add(ggml-hrx-deps … CMAKE_ARGS ${GGML_HRX_CMAKE_ARGS}). The outer llama.cpp build keeps -Werror for these three diagnostics, so a real out-of-bounds in this tree still fails.
  • only GCC ≥ 15: if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15), so an older compiler keeps the promotion.
  • -Wno-error=, not -Wno-: every diagnostic stays in the log, only the promotion goes. The three flags parse on this box's gcc 15.2.0 — the version the comment says they reproduced the warnings on, which I confirmed (gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0), and a compile with all three is clean.

The disclosure is the part that makes this reviewable. Two of the three are argued as false positives with the reasoning that proves it in the comment (IREE's next_head_index is pre-incremented inside the do-while and bounded before it, so the subscript is in 0..count-1; loom's lane_count is bounded by 128 for every carrier the table admits, so padded_lane_count ≤ 128) — that is the shape a suppression needs. The third is called out as not a false positive: loom/tooling/testbench/expectation.c:1112 formats with %.*s and an empty string view can carry a NULL data pointer, so NULL can reach %s — latent UB, in an error-message path of a testbench tool, in AMD's tree which this fork must not modify. Demoting it in the deps build is the only place the fork can act, and it cannot change a shipped code path. Naming that instead of filing it under "GCC 15 noise" is the difference between a documented workaround and a hidden bug.

Not checked: the two source lines themselves (continuation.h:75, transpose.c:366, expectation.c:1112) — they live in the fetched IREE/loom trees, not in this repository, and the HRX deps build is the hour-long ExternalProject I have not spent for a warning-policy change. The upstream fix would be to send the %.*s/NULL case to AMD; until then this is the right seam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant