Fixing segfault crashes when using measure/reset ops. #217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is probably a regression since #167
Specifically,
flushRequestedAllocations()
is not called when handling measurement at the concreteExecutionManager
implementation (i.e.,QIRExecutionManager
) with the assumption that it has been called duringexecuteInstruction()
.This will lead to a Segfault in this case (no gates)
For
reset
gate, there is a subtle issue w.r.t. gate ordering (leading to segfault eventually):ExecutionManager::resetQudit
is skipped by the middleBasicExecutionManager
(where instruction batching occurs) and only implemented by the concrete subclassQIRExecutionManager
->reset
op could be dispatched out of order due to nosynchronize()
call (-> segfault due to noflushRequestedAllocations
call).Changes
Rename
ExecutionManager::resetQudit
->ExecutionManager::reset
and useBasicExecutionManager::resetQudit
as the pure virtual method for sub-class implementation. This is to make it consistent with howmeasure
is handled.Add
flushRequestedAllocations()
call tomeasureQudit
/measureSpinOp
/resetQudit
implementations.Add unit test cases.