Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiagonalFusion::aggregate_operations can crash in some circumstances #2291

Open
aromanro opened this issue Jan 16, 2025 · 0 comments
Open

DiagonalFusion::aggregate_operations can crash in some circumstances #2291

aromanro opened this issue Jan 16, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@aromanro
Copy link
Contributor

aromanro commented Jan 16, 2025

Informations

  • Qiskit Aer version: Latest development version
  • Python version: Not relevant as qiskit aer was used from C++ when noticing it
  • Operating system: Windows 11

What is the current behavior?

I was testing the MPS simulator with some randomly generated circuits... with some I've got crashes.
The call chain (a part of it) of this reported crash is AerState::apply_measure -> AerState::flush_ops -> AerState::transpile_ops -> Fusion::optimize_circuit -> ... -> DiagonalFusion::get_next_diagonal_end -> DiagonalFusion::is_diagonal_op

The last call is with an invalid op. The problem occurs because DiagonalFusion::get_next_diagonal_end gets an invalid from parameter.
The ops list had 102 size and next_diagonal_start was 102.

Steps to reproduce the problem

This would be probably hard to reproduce, I was generating some random circuits with more than 100 ops to test some things and maybe one in 100 circuits crashed (it's just an order of magnitude guesstimation), probably related with this (I also found this #2286 during the tests).

What is the expected behavior?

No crash.

Suggested solutions

DiagonalFusion::get_next_diagonal_end

int DiagonalFusion::get_next_diagonal_end(
could have this check added right at the beginning:

  if (ops.size() <= from)
    return -1;
@aromanro aromanro added the bug Something isn't working label Jan 16, 2025
aromanro added a commit to InvictusWingsSRL/qiskit-aer that referenced this issue Jan 16, 2025
aromanro added a commit to InvictusWingsSRL/qiskit-aer6 that referenced this issue Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant