Skip to content

fix(rocalution): fix alloc-dealloc mismatch in HostMatrixCSR::ILUTFactorize - #13943

Merged
amontoison merged 2 commits into
ROCm:developfrom
amontoison:rocalution-ilut-alloc-mismatch
Oct 27, 2026
Merged

amontoison merged 2 commits into
ROCm:developfrom
amontoison:rocalution-ilut-alloc-mismatch

Conversation

@amontoison

@amontoison amontoison commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Under ASAN, rocalution-test aborts on bicgstab/parameterized_bicgstab.bicgstab_float/20

ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs free)

HostMatrixCSR::ILUTFactorize allocates col, val and temp_pivot_buffer with allocate_host (new[]), but grows col / val with realloc() and releases all three with free().

Technical details

  • All three buffers stay on allocate_host and are now released with free_host().
  • col / val are grown by allocating a larger buffer with allocate_host, copying the rows stored so far (row_offset[i] entries) with copy_h2h, and releasing the old one, instead of realloc().
  • The free space is derived from row_offset[i], which removes remaining_nnz. Its growth over-counted the space added (it added 1.5 times the already-grown nnz). The new size is max(1.5 * nnz, row_offset[i] + store_size), so a single growth always fits the current row.
  • allocate_host aborts on failure, so the realloc failure branch, which could free col twice, is removed.
  • The initial size min(2 * maxrow, nrow) * nrow is computed in 64-bit so it cannot overflow int.

Test plan

rocalution-test built with BUILD_ADDRESS_SANITIZER=ON and run with the ticket's ASAN_OPTIONS.

Test result

Fixes the ASAN abort.

JIRA ID: ROCM-33012

…torize

temp_pivot_buffer was allocated with new[] and released with free().
col/val were allocated with new[] but grown with realloc and released
with free(); allocate them with malloc instead. Also fix remaining_nnz
bookkeeping on reallocation, which overestimated the free space.
@therock-pr-bot

therock-pr-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocalution/src/base/host/host_matrix_csr.cpp; no test file found
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

Keep col and val on allocate_host and release them with free_host.
Grow them by allocating a larger buffer, copying the rows stored so far
and releasing the old one, instead of realloc().

Derive the free space from row_offset[i], which removes remaining_nnz.
allocate_host aborts on failure, so the realloc failure branch, which
could free col twice, is gone. Compute the initial size in 64-bit so
that min(2 * maxrow, nrow) * nrow cannot overflow int.

JIRA ID: ROCM-33012

Co-authored-by: Nico Trost <nico.trost@amd.com>
@amontoison
amontoison requested a review from a team as a code owner October 26, 2026 05:49
@amontoison
amontoison requested a review from ntrost57 October 26, 2026 21:26
@amontoison
amontoison merged commit 29d3639 into ROCm:develop Oct 27, 2026
88 checks passed
@amontoison
amontoison deleted the rocalution-ilut-alloc-mismatch branch October 27, 2026 15:52
@assistant-librarian

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

ntrost57 added a commit that referenced this pull request Oct 30, 2026
The accelerator Amax returns a zero-based index since #14185, stopping
rocalution resets the accelerator flag since #14103, ILUT computes the
row limit in 64 bit since #13943, and the iterative U solve of a HIP
matrix has its own analysis since #14186. Run these checks on both
backends again, without KNOWN_BUG and expect_in_child. The complex
accelerator Amax stays a known bug, since rocblasTamax is a stub there.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants