Skip to content

Segmentation fault on Qt5Agg when using the wrong linestyle #6816

Closed

Description

@Dapid

The following program triggers an Python error and a segmentation fault (notice that the correct linestyle is -.):

import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as plt
plt.hist([0, 1, 1, 2], linestyle='.-')
plt.show()

plot sanitizes the input, so this just produces a ValueError.
import matplotlib.pyplot as plt
plt.plot([0, 1], [1, 2], linestyle='.-')

The backends Qt4Agg and TkAgg also raise an error, but don't produce a hard crash.

My system is Python 3.5 on a virtual environment with matplotlib built from source via pip.

Full traceback for the aborting snippet:

Traceback (most recent call last):
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/backends/backend_qt5agg.py", line 176, in __draw_idle_agg
    FigureCanvasAgg.draw(self)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/backends/backend_agg.py", line 474, in draw
    self.figure.draw(self.renderer)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/figure.py", line 1159, in draw
    func(*args)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 2324, in draw
    a.draw(renderer)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/patches.py", line 494, in draw
    gc.set_linestyle(self._linestyle)
  File "/home/david/.virtualenv/py35/lib/python3.5/site-packages/matplotlib/backend_bases.py", line 1064, in set_linestyle
    raise ValueError('Unrecognized linestyle: %s' % str(style))
ValueError: Unrecognized linestyle: .-
Aborted (core dumped)

Activity

  1. added this to the milestone on Jul 22, 2016
  2. tacaswell commented on Jul 22, 2016

    @tacaswell
    Member

    What version of mpl are you using?

  3. Dapid commented on Jul 22, 2016

    @Dapid
    Author

    Sorry, I forgot. 1.5.1, latest on Pypi

  4. anntzer commented on Sep 6, 2016

    @anntzer
    Contributor

    I can confirm the issue as of 1.5.1 and PyQt 5.6 (5.7 doesn't work with 1.5.1), but it is fixed as of 2.0b3 with both PyQt5.6 and 5.7.

  5. tacaswell commented on Sep 6, 2016

    @tacaswell
    Member

    @anntzer do we have any idea what fixed it? There is likely to still be a 1.5.3.

  6. anntzer commented on Sep 6, 2016

    @anntzer
    Contributor

    Bisected back to 3ef3f5b (basically, throwing exceptions at draw time is always going to be fatal for Qt5).

  7. tacaswell commented on Sep 6, 2016

    @tacaswell
    Member

    ew, that is not something we can backport to 1.5

    I suspect we are going to be playing wack-a-mole with qt5 for a while if raising at draw time is fatal...

  8. anntzer commented on Sep 6, 2016

    @anntzer
    Contributor

    See http://pyqt.sourceforge.net/Docs/PyQt5/incompatibilities.html#unhandled-python-exceptions
    Basically you can avoid this by overwriting sys.excepthook, but I'd rather not go that route...

  9. tacaswell commented on Sep 6, 2016

    @tacaswell
    Member

    I guess in __draw_idle_agg we could catch and print the exceptions? That would get us back to the status-quo without overriding it for the rest of qt5?

  10. anntzer commented on Sep 6, 2016

    @anntzer
    Contributor

    I guess that could work, yes.

  11. modified the milestones: , on Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions