Skip to content

Conversation

@rietmann-nv
Copy link
Contributor

I came across this issue when running larger solves on GPUs. The error was in par_krylov_func.c

array_data = hypre_CTAlloc(HYPRE_Complex, (n * size * num_vectors), memory_location);

The expression n * size * num_vectors overflowed, leading to undefined behavior and crashes. I found a number of other places where this could possibly happen and fixed them as well, but they are less likely because they don't have the extra n parameter.

These fixes ensure that the HYPRE library correctly handles large vectors and matrices without integer overflow issues when configured
  with 32-bit integers (HYPRE_MIXEDINT defined).
@liruipeng
Copy link
Contributor

@rietmann-nv Thanks for reporting the bug. We had another PR for this issue #1421 . We will merge yours to that PR, and then to master.

@liruipeng liruipeng changed the base branch from master to amgfix December 18, 2025 16:50
@liruipeng liruipeng changed the base branch from amgfix to master December 18, 2025 16:53
@liruipeng liruipeng changed the base branch from master to amgfix December 18, 2025 16:54
@liruipeng liruipeng merged commit 6fe3e8d into hypre-space:amgfix Dec 18, 2025
liruipeng added a commit that referenced this pull request Jan 9, 2026
* fix int overflow

* Casts to avoid overflow of 32-bit integers before casting to uint64 (#1440)

These fixes ensure that the HYPRE library correctly handles large vectors and matrices without integer overflow issues when configured
  with 32-bit integers (HYPRE_MIXEDINT defined).

Co-authored-by: Rui Peng Li <[email protected]>

---------

Co-authored-by: Max Rietmann <[email protected]>
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.

2 participants