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

Abort on wrong parameter type

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 5.13.0
    • 5.13.2
    • Shiboken
    • None
    • Fedora 30, Qt 5.13.0-beta3, Python 3.7.3
    • Linux/X11
    • 1eb777f3846685b366207827a9c01a874cda91c8 (pyside/pyside-setup/5.13)

    Description

      Calling a C++ method from Python with arguments of a wrong type may cause an abort.

      I have a method accepting a const QMap<QString, QString>& as a parameter. Calling this method with a dict containing only string values works fine:

      Working example
      ri = RpcInterface(True)
      props = {
          "offsetX": "0",
          "offsetY": "0",
          "width": "3",
          "height": "4" # Remove quotations to induce abort
      }
      print(ri.some_rpc_call(props)) # Works fine
      

      If, however, the dict contains even a single non-string value, calling this method causes an abort:

      Example that causes an abort
      ri = RpcInterface(True)
      props = {
          "offsetX": "0",
          "offsetY": "0",
          "width": "3",
          "height": 4 # Oops, forgot the quotation marks...
      }
      print(ri.some_rpc_call(props)) # Abort!
      

      Stack trace from the abort (generated with ipython3, but the problem also occurs with regular python3):

      Abort message (sensitive data retracted, sorry)
      Traceback (most recent call last):
        File "/usr/local/lib64/python3.7/site-packages/shiboken2/files.dir/shibokensupport/signature/loader.py", line 111, in seterror_argument
          return errorhandler.seterror_argument(args, func_name)
        File "/usr/local/lib64/python3.7/site-packages/shiboken2/files.dir/shibokensupport/signature/errorhandler.py", line 98, in seterror_argument
          func = eval(func_name, namespace)
        File "<string>", line 1, in <module>
      NameError: name 'Universe' is not defined
      
      If you suspect this is an IPython bug, please report it at:
          https://github.com/ipython/ipython/issues
      or send an email to the mailing list at ipython-dev@python.org
      
      You can print a more detailed traceback right now with "%tb", or use "%debug"
      to interactively debug it.
      
      Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
          %config Application.verbose_crash=True
      
      Fatal Python error: seterror_argument did not receive a result
      
      Thread 0x00007f75298e5700 (most recent call first):
        File "/usr/lib64/python3.7/threading.py", line 296 in wait
        File "/usr/lib64/python3.7/threading.py", line 552 in wait
        File "/usr/lib/python3.7/site-packages/IPython/core/history.py", line 829 in run
        File "/usr/lib/python3.7/site-packages/IPython/core/history.py", line 58 in needs_sqlite
        File "<decorator-gen-24>", line 2 in run
        File "/usr/lib64/python3.7/threading.py", line 917 in _bootstrap_inner
        File "/usr/lib64/python3.7/threading.py", line 885 in _bootstrap
      
      Current thread 0x00007f7538323680 (most recent call first):
        File "/home/<USER>/Projekte/<CLIENT>/pyside-setup/examples/build-samplebinding-Importiertes_Kit-Vorgabe/main.py", line 14 in <module>
        File "/usr/lib/python3.7/site-packages/IPython/utils/py3compat.py", line 188 in execfile
        File "/usr/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2683 in safe_execfile
        File "/usr/lib/python3.7/site-packages/IPython/core/shellapp.py", line 340 in _exec_file
        File "/usr/lib/python3.7/site-packages/IPython/core/shellapp.py", line 408 in _run_cmd_line_code
        File "/usr/lib/python3.7/site-packages/IPython/core/shellapp.py", line 288 in init_code
        File "/usr/lib/python3.7/site-packages/IPython/terminal/ipapp.py", line 322 in initialize
        File "/usr/lib/python3.7/site-packages/traitlets/config/application.py", line 87 in catch_config_error
        File "<decorator-gen-112>", line 2 in initialize
        File "/usr/lib/python3.7/site-packages/traitlets/config/application.py", line 657 in launch_instance
        File "/usr/lib/python3.7/site-packages/IPython/__init__.py", line 125 in start_ipython
        File "/usr/bin/ipython3", line 5 in <module>
      zsh: abort (core dumped)  LD_LIBRARY_PATH=. ipython3 main.py
      

      It appears as if the error handler in the shiboken module attempts to build a meaningful error message, but causes a NameError due to trying to access my module by name.

      Please note that I do not copy any generated libraries to any system paths, executing my test script inside the build folder and adding it to sys.path. However, copying the binaries into my Python 3 installation's site-packages folder, where all PySide and shiboken packages can be found, does not fix the problem.

      I build a small example project out of the samplebindings example. Please refer to the included README file.

      Attachments

        1. param-type-abort.zip
          17 kB
        2. pyside1009_stack.txt
          2 kB
        3. pyside1009.zip
          16 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ctismer Christian Tismer
            snkauoe Sebastian Kaupe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes