qiskit-metal
qiskit-metal copied to clipboard
Occasional segmentation fault on exit
Informations
- Qiskit Metal version: all
- Python version: all
- Operating system: Mac
What is the current behavior?
Sometimes when the metal gui exits a segmentation fault is thrown. This appears to occur on Mac, but has not (to my knowledge) been seen on WinX or Linux.
Note: The failure does not occur when running the code in VS Code in debug mode.
Steps to reproduce the problem
Repeatable by rapidly starting and closing the GUI - you can do that by executing test_gui_basic.py over and over.
What is the expected behavior?
No segmentation fault
Suggested solutions
n/a
Just some FYI that may help resolve this issue. @dwang429 and @grace-harper-ibm sharing information that we observed today.
Ipython sets up the event loop within Jupyter notebooks so Metal code and Metal user does not start the event loop.: https://ipython.readthedocs.io/en/stable/config/eventloops.html
.
If using a script, the event loop is not explicitly started within code. Can write: sys.exit(gui.qApp.exec_())
to focus on the GUI. When doing this, the focus switches from script to GUI. When the GUI would close, the script could segv.
https://stackoverflow.com/questions/28060218/where-is-pyqt-event-loop-running
This post does not explain all that is happening for this issue. However, it could be helpful.
So within the
@priti-ashvin-shah-ibm @dwang429 It looks like Metal was written with IPython in mind. However the closing of the app seems to follow a nontraditional format.
Both script & Jupyter notebooks fail to exit cleanly even when running gui.main_window.close()
in notebooks.
Possible options to consider:
Check if starting https://github.com/ankitects/anki
in a script, having more code after the start, and running the script will cause ungraceful exit. If not, consider taking anki
's approach.
If it fails, then we need to further consider how to have the Metal GUI as a standalone that can still be run gracefully in Jupyter Notebooks and a script.