Skip to content

Conversation

@rafal-c
Copy link

@rafal-c rafal-c commented Mar 10, 2025

Calling write_matrix_market_csc on a sparse array with no explicit values hangs indefinitely. This is caused by the fact that inside csc_formatter::chunk::next_chunk, there is a division by nnz_per_column, which happens to be 0. for such arrays.

The fix I propose here is to set ptr_chunk_end to the end of range in the problematic case, avoiding division by zero.

An alternative fix could be to call write_body inside write_matrix_market_csc only if nnz > 0, but it doesn't really solve the problem within the csc_formatter.

I also updated unit tests to cover the case of a csc matrix with no explicit values and non-zero dimensions.

rafal-c added 2 commits March 10, 2025 18:00
…tter::chunk::next_chunk. Trying to calculate the chunk size with nnz_per_columns being 0, which may happen for sparse arrays with no explicit values, results in an undefined behavior (division by 0).
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