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

QJsonDocument.toVariant() segfaults if JSON contains a null value

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.12.0
    • 5.11.2
    • PySide, Shiboken
    • None
    • macOS 10.13.6

      Python 3.6, 3.7 (tried on both)

      Qt 5.11.2

      QfP 5.11 branch at commit {{8383c2ff7f383385707bd2fc3e33071988507910}}
    • All
    • 3c2ef04c9eade4226f139064c6c45cb4819834e0 (pyside/pyside-setup/5.12)

    Description

      Minimal example to replicate crash:

      from PySide2.QtCore import QJsonDocument
      
      QJsonDocument.fromJson(b'{"test": null}').toVariant()
      

      Which causes an immediate segfault.

      For a hint at what may be going on, if you pass in a JSON document that contains an array with a null, rather than a null directly, like so:

      from PySide2.QtCore import QJsonDocument
      
      QJsonDocument.fromJson(b'{"test": [null]}').toVariant()
      

      Raises a Python exception, not a segfault:

      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      RuntimeError: Can't find converter for 'std::nullptr_t'.
      

      So perhaps what needs to be done is the Variant converters need to handle the special case of turning null values into Py_None

      Attachments

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

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            empyrical empyrical
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes