Issue 1:
Bug report

A segmentation fault happening with PySide2 5.12.1 but not with 5.11.0.

This might be an upstream issue.

Code for reproduction

import sys
import faulthandler
faulthandler.enable(file=sys.stdout)

from matplotlib import rcParams
from matplotlib.backends.backend_qt5agg import FigureCanvas as Canvas
from matplotlib.figure import Figure
from PySide2.QtWidgets import QApplication, QVBoxLayout, QWidget

class MatplotlibWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.canvas = Canvas(Figure())
vertLayout = QVBoxLayout()
vertLayout.addWidget(self.canvas)
self.setLayout(vertLayout)
self.axes = self.canvas.figure.add_subplot(111)

if __name__ == "__main__":
qapp = QApplication(sys.argv)
app = MatplotlibWidget()
app.axes.plot(range(12), range(12))
app.show()
qapp.exec_()

Actual outcome

This code works fine for PySide2 5.11.0 but crashes for 5.12.1:

Fatal Python error: Segmentation fault

Current thread 0x00000001142cb5c0 (most recent call first):
File "<frozen importlib._bootstrap_external>", line 525 in _compile_bytecode
File "<frozen importlib._bootstrap_external>", line 857 in get_code
File "<frozen importlib._bootstrap_external>", line 724 in exec_module
File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 983 in _find_and_load
File "/usr/local/lib/python3.7/site-packages/matplotlib/projections/__init__.py", line 3 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 728 in exec_module
File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 983 in _find_and_load
File "/usr/local/lib/python3.7/site-packages/matplotlib/figure.py", line 42 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 728 in exec_module
File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 983 in _find_and_load
File "/usr/local/lib/python3.7/site-packages/matplotlib/backends/backend_qt5.py", line 17 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 728 in exec_module
File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 983 in _find_and_load
File "/usr/local/lib/python3.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 11 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 728 in exec_module
File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 983 in _find_and_load
File "script.py", line 6 in <module>
[1] 98230 segmentation fault python3 script.py

Matplotlib version

Operating system: macOS X 10.14.3

Matplotlib version: 3.0.2

Python version: 3.7.2

Issue 2:
Bug report

Bug summary

Importing matplotlib after PySide2 is imported causes crash occasionally. When the order of imports is reversed, the occasional crash goes away. I'm not sure whether this is PySide2's problem or Matplotlib's. I've also reported this bug on Qt Bug Tracker.

Code for reproduction

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *

print('pyside')

import matplotlib.pyplot

print('matplotlib')

Actual outcome

No specific error message, I only got this:

Process finished with exit code -1073741819 (0xC0000005)

Matplotlib version

Operating system: Windows 10 64-bit

Matplotlib version: 3.0.2

Matplotlib backend (print(matplotlib.get_backend())): TkAgg

Python version: 3.7.2 64-bit

Other libraries: PySide2/shiboken2: 5.12.1

Matplotlib, PySide2/shiboken2 were all installed via pip.