馃 AI text below 馃
System and Environment Information
- MQT Core: current
main and the 3.9 QDMI device implementation
- QDMI: 1.3.3
- Language: C++20
- Platforms: all supported platforms; the issue is independent of the operating system and compiler
Bug Description
Two allocation-capable entry points in the superconducting QDMI provider can let C++ exceptions escape through the C API:
MQT_SC_QDMI_device_session_set_parameter calls setDeviceConfigurationParameter, which constructs and assigns strings and filesystem paths.
MQT_SC_QDMI_device_session_create_device_job allocates a job and inserts it into an unordered_map.
An allocation failure can therefore throw std::bad_alloc instead of returning QDMI_ERROR_OUTOFMEM. Other unexpected exceptions from an entry point can also cross the C boundary instead of returning QDMI_ERROR_FATAL.
The current QDMI-on-IQM implementation needs the same protection. IQM_QDMI_device_session_set_parameter constructs strings, and IQM_QDMI_device_session_create_device_job uses throwing new without an exception barrier.
QMAP inherited this behavior in its neutral-atom provider and contains it in munich-quantum-toolkit/qmap@4bd4c153. That change makes the allocation-capable methods non-throwing, maps std::bad_alloc to QDMI_ERROR_OUTOFMEM, maps other exceptions to QDMI_ERROR_FATAL, and keeps the output job handle null on failure.
Steps to Reproduce
- Allocate a superconducting QDMI device session.
- Inject an allocation failure while copying a device configuration parameter, or initialize the session and inject a failure while creating a device job.
- Call the corresponding exported device function.
- Observe that
std::bad_alloc escapes instead of producing a QDMI status code.
The exported C entry points should contain every exception. They should return QDMI_ERROR_OUTOFMEM for allocation failures, return QDMI_ERROR_FATAL for other unexpected failures, and leave output handles in a documented safe state.
馃 AI text below 馃
System and Environment Information
mainand the 3.9 QDMI device implementationBug Description
Two allocation-capable entry points in the superconducting QDMI provider can let C++ exceptions escape through the C API:
MQT_SC_QDMI_device_session_set_parametercallssetDeviceConfigurationParameter, which constructs and assigns strings and filesystem paths.MQT_SC_QDMI_device_session_create_device_joballocates a job and inserts it into anunordered_map.An allocation failure can therefore throw
std::bad_allocinstead of returningQDMI_ERROR_OUTOFMEM. Other unexpected exceptions from an entry point can also cross the C boundary instead of returningQDMI_ERROR_FATAL.The current QDMI-on-IQM implementation needs the same protection.
IQM_QDMI_device_session_set_parameterconstructs strings, andIQM_QDMI_device_session_create_device_jobuses throwingnewwithout an exception barrier.QMAP inherited this behavior in its neutral-atom provider and contains it in munich-quantum-toolkit/qmap@4bd4c153. That change makes the allocation-capable methods non-throwing, maps
std::bad_alloctoQDMI_ERROR_OUTOFMEM, maps other exceptions toQDMI_ERROR_FATAL, and keeps the output job handle null on failure.Steps to Reproduce
std::bad_allocescapes instead of producing a QDMI status code.The exported C entry points should contain every exception. They should return
QDMI_ERROR_OUTOFMEMfor allocation failures, returnQDMI_ERROR_FATALfor other unexpected failures, and leave output handles in a documented safe state.