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

app crash after deleting C++-created objects

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 1.2.2, dev
    • Fix Version/s: 5.9
    • Component/s: PySide
    • Labels:
    • Environment:
      Tested on Windows 7, Python 3.4, PySide 1.2.2 and on Ubuntu 12.04 with Python 3.4, Qt 4.8 and PySide 1.2.2.
    • Commits:
      819f7b47b1fcdc2ed88bdd07383bbd37a76848ac

      Description

      Example of crashing code is in attachment.

      Here's explanation of the issue as far as I could understand:

      self.view.addItem('AAA')
      

      Method addItem creates instance of QListWidgetItem. It's plain C++ object without any Python wrapper.

      self.view.item(0)
      

      Method QListWidget.item creates Python wrapper for created object and links it to the list using function Shiboken::Object::setParent, so the wrapper remains live till the exit from application potentially.

      self.view.clear()
      

      QListWidget.clear() clears internal list and destroys every item in it. After this the item object does no more exist, but the corresponding Python wrapper still does and it isn't marked as pointing to invalid object.

      So there is two main ways how we can crash program using this invalid wrapper. The first is pretty obvious: try to call any method of previously acquired wrapper. Like in method crash1 from example.

      The second way is more vague, and I don't understand the mechanism behind that, but it is more likely to occur and more dangerous. The crash occurs when you instantiate any descendant of QWidget class. It can be absolutely unrelated to the use of item() method so it's very hard to diagnose.

        Attachments

        For Gerrit Dashboard: PYSIDE-264
        # Subject Branch Project Status CR V

          Activity

            People

            • Assignee:
              crmaurei Cristian Maureira-Fredes
              Reporter:
              veon Andrey Golynskiy
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Gerrit Reviews

                There are no open Gerrit changes