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

Smart pointer conversion code (introduced with shiboken 6.8.x?) crashes depending on order of AddTypeCreationFunction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.8.2
    • 6.8.1, 6.8.0.2
    • Shiboken
    • None
    • Linux/X11, Windows
    • eba68313c (dev), 3d3816a2b (dev), 6df09a034 (6.8), 0b2d89818 (6.8), 206b907de (dev), 3da05cc76 (dev), cd24cc94f (6.8), b079b6360 (6.8)

      It seems that shiboken 6.8.x introduced changes in the SmartPointer handling. In the generated _wrapper.cpp files, there is a new section

          // Convert to SmartPointer derived class: [QSharedPointer<QObject>]
          Shiboken::Conversions::addPythonToCppValueConversion(Shiboken::Conversions::getConverter("QSharedPointer<QObject>"),
              QSharedPointer_nexxT_Port__PythonToCpp_QSharedPointer_QObject_,
              is_QSharedPointer_nexxT_Port__PythonToCpp_QSharedPointer_QObject__Convertible);
          ///////////////////////////////////////////////////////////////////////////////////////
      
      

      in the init_QSharedPointer_<type> functions (in the example posted here, type is nexxT_Port). For my project, this results in a segmentation fault as soon as I try to import the wrapper module. Ive tried out 3 things:

      1. Comment out the new conversion code and recompile. The crash is gone in this case.
      2. In the module_wrapper.cpp PyInit() function, fix the order of AddTypeCreationFunction from

          // not working!
          Shiboken::Module::AddTypeCreationFunction(module, "QSharedPointer_nexxT_Port", init_QSharedPointer_nexxT_Port);
          Shiboken::Module::AddTypeCreationFunction(module, "QSharedPointer_QObject", init_QSharedPointer_QObject);
      

      to

          // working
          Shiboken::Module::AddTypeCreationFunction(module, "QSharedPointer_QObject", init_QSharedPointer_QObject);
          Shiboken::Module::AddTypeCreationFunction(module, "QSharedPointer_nexxT_Port", init_QSharedPointer_nexxT_Port);
      

      This also results in the crash being fixed.

      3. I also tried to create a minimal example, but I failed. I can attach the WIP to the issue if necessary.

        1. stacktrace.txt
          12 kB
          a dev
        2. valgrind.log
          13 kB
          a dev
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kleint Friedemann Kleint
            bdev a dev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: