glue icon indicating copy to clipboard operation
glue copied to clipboard

Segmentation fault on zoom following tutorial

Open mrclary opened this issue 2 years ago • 1 comments

Describe the bug A segmentation fault 11 occurs when attempting to zoom on image from tutorial; gif attached.

To Reproduce Steps to reproduce the behavior such as:

  1. create virtual environment for glue and install from local repository (v1.4.0)
$ pyenv virtualenv 3.10.3 glue
$ pyenv activate glue
(glue) $ pip install .
  1. Launch glue
(glue) $ glue
  1. import data from tutorial and create the 2D image.
  2. Attempt to zoom on the image
Traceback (most recent call last):
  File "/Users/rclary/.pyenv/versions/3.10.3/envs/glue/lib/python3.10/site-packages/glue/viewers/matplotlib/qt/widget.py", line 81, in paintEvent
    self._draw_zoom_rect(painter)
  File "/Users/rclary/.pyenv/versions/3.10.3/envs/glue/lib/python3.10/site-packages/glue/viewers/matplotlib/qt/widget.py", line 108, in _draw_zoom_rect
    painter.drawRect(*(pt / dpi_ratio for pt in rect))
TypeError: arguments did not match any overloaded call:
  drawRect(self, QRectF): argument 1 has unexpected type 'float'
  drawRect(self, int, int, int, int): argument 1 has unexpected type 'float'
  drawRect(self, QRect): argument 1 has unexpected type 'float'
QBackingStore::endPaint() called with active painter; did you forget to destroy it or call QPainter::end() on it?
QPainter::begin: A paint device can only be painted by one painter at a time.
QPainter::setCompositionMode: Painter not active
Segmentation fault: 11

Expected behavior Show the zoomed image and don't crash

Screenshots glue

Details:

  • Operating System: MacOS 11.6.6
  • Python version (python --version): 3.10.3
  • Glue version (glue --version): 1.4.0
  • How you installed glue: pip
Environment
Package             Version
------------------- -----------
appnope             0.1.3
astropy             5.1
asttokens           2.0.5
backcall            0.2.0
casa-formats-io     0.1
cloudpickle         2.1.0
cycler              0.11.0
dask                2022.5.2
debugpy             1.6.0
decorator           5.1.1
dill                0.3.5.1
echo                0.6
entrypoints         0.4
et-xmlfile          1.1.0
executing           0.8.3
fast-histogram      0.11
fonttools           4.33.3
fsspec              2022.5.0
glue-core           1.4.0
h5py                3.7.0
ipykernel           6.13.0
ipython             8.4.0
ipython-genutils    0.2.0
jedi                0.18.1
joblib              1.1.0
jupyter-client      7.3.1
jupyter-core        4.10.0
kiwisolver          1.4.2
locket              1.0.0
matplotlib          3.5.2
matplotlib-inline   0.1.3
mpl-scatter-density 0.7
nest-asyncio        1.5.5
numpy               1.22.4
openpyxl            3.0.10
packaging           21.3
pandas              1.4.2
parso               0.8.3
partd               1.2.0
pexpect             4.8.0
pickleshare         0.7.5
Pillow              9.1.1
pip                 22.1.2
prompt-toolkit      3.0.29
psutil              5.9.1
ptyprocess          0.7.0
pure-eval           0.2.2
pvextractor         0.3
pyerfa              2.0.0.1
Pygments            2.12.0
pyparsing           3.0.9
PyQt5               5.15.6
PyQt5-Qt5           5.15.2
PyQt5-sip           12.10.1
python-dateutil     2.8.2
pytz                2022.1
PyYAML              6.0
pyzmq               23.1.0
qtconsole           5.3.0
QtPy                2.1.0
radio-beam          0.3.3
scipy               1.8.1
setuptools          62.3.2
six                 1.16.0
spectral-cube       0.6.0
stack-data          0.2.0
toolz               0.11.2
tornado             6.1
traitlets           5.2.2.post1
wcwidth             0.2.5
xlrd                2.0.1

mrclary avatar Jun 04 '22 02:06 mrclary

After looking into this a bit, it looks to be a Python 3.10 issue. In particular, the culprit is this change, which breaks the implicit float -> int conversion that was present in earlier CPython versions.

The offending line in glue is here. The signature of the drawRect overload that we end up calling is drawRect(self, int, int, int, int), while the values in *(pt / dpi_ratio for pt in rect) are all float. Using the QRectF overload instead (or, alternatively, explicitly converting these values to integers) should fix the issue.

Carifio24 avatar Jun 21 '22 16:06 Carifio24