Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-641

Segmentation fault when adding certain kinds of classes to userData

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Fixed
    • Affects Version/s: 5.6
    • Fix Version/s: 5.11.1
    • Component/s: PySide
    • Labels:
    • Environment:
      MacOS X 10.13.4, PySide2 installed with conda from the conda-forge channel.
    • Commits:
      aa75437f9119d997dd290471ac3e2cc88ca88bf1

      Description

      When adding items to a combo box with userData, a segmentation fault can occur if the object implements ``__getitem__`` in a certain way. Example:

      from PySide2.QtWidgets import QApplication, QComboBox
      from PySide2.QtCore import QObject
      
      
      class Test(object):
          def __getitem__(self, key):
              raise KeyError("HEY")
      
      
      app = QApplication([''])
      combo = QComboBox()
      combo.addItem('a', userData=Test())
      print(combo.itemData(0))

      This code leads to a segmentation fault - here's an extract from the MacOS X report:

      Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
      0 QtCore.cpython-36m-darwin.so 0x00000001060a5bbd QVariant_isStringList(_object*) + 29
      1 QtCore.cpython-36m-darwin.so 0x000000010609e5cf PySequence_PythonToCpp_QVariant(_object*, void*) + 31
      2 QtWidgets.cpython-36m-darwin.so	0x0000000101eaa00c Sbk_QComboBoxFunc_addItem(_object*, _object*, _object*) + 604
      3 libpython3.6m.dylib 0x00000001013fc837 _PyCFunction_FastCallDict + 183
      4 libpython3.6m.dylib 0x00000001013fca4b _PyCFunction_FastCallKeywords + 75
      5 libpython3.6m.dylib 0x0000000101480597 call_function + 439
      6 libpython3.6m.dylib 0x000000010147cf78 _PyEval_EvalFrameDefault + 25096
      7 libpython3.6m.dylib 0x00000001014813dc _PyEval_EvalCodeWithName + 3436
      8 libpython3.6m.dylib 0x0000000101476ca4 PyEval_EvalCode + 100
      9 libpython3.6m.dylib 0x00000001014ac841 PyRun_FileExFlags + 209
      10 libpython3.6m.dylib 0x00000001014ac0ee PyRun_SimpleFileExFlags + 846
      11 libpython3.6m.dylib 0x00000001014c5a96 Py_Main + 3526
      12 python 0x000000010139adf8 main + 232
      13 libdyld.dylib 0x00007fff70753015 start + 1

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              • Assignee:
                crmaurei Cristian Maureira-Fredes
                Reporter:
                trobitaille trobitaille
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes