Skip to content

[[]] * size in qgather causes silent data corruption #2

@CardamaS99

Description

@CardamaS99

Description

File: netqmpi/sdk/primitives/collective/collective.py (line ~95)

Problem

received_qubits = [[]] * size

This creates size references to the same list object. Although assignment with = by index currently works, if .append() is used in the future, everything would be silently corrupted.

This is a dangerous anti-pattern in Python.

Solution

received_qubits = [[] for _ in range(size)]

Impact

  • Severity: Critical
  • Affects: qgather with multiple nodes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority: criticalMust fix before release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions