qiskit-metal icon indicating copy to clipboard operation
qiskit-metal copied to clipboard

Occasional segmentation fault on exit

Open JeremyDrysdale-ibm opened this issue 4 years ago • 2 comments

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

JeremyDrysdale-ibm avatar Nov 17 '20 13:11 JeremyDrysdale-ibm

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 avatar Dec 14 '20 20:12 priti-ashvin-shah-ibm

@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.

ghost avatar Dec 15 '20 17:12 ghost