Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash with Qt 5.4.2 when .py files are loaded from Qt Resources #46

Closed
gdtroszak opened this issue Jun 3, 2015 · 12 comments
Closed

Crash with Qt 5.4.2 when .py files are loaded from Qt Resources #46

gdtroszak opened this issue Jun 3, 2015 · 12 comments

Comments

@gdtroszak
Copy link

I'm attempting to run the listmodel example on OS X Yosemite to no avail. Below is the head of the problem report and the stack trace of the crashed thread. It looks like something is going awry when converting the python list to a javascript array? Out of curiosity, I modified the example a bit so that the python function simply returned a string and everything worked just fine.

I've installed a packaged version of Qt 5.4.2, am using python 3.4.3 installed via homebrew, and pyotherside 1.4.0 has been installed as described in the project README.

I've searched for a solution, but didn't have much luck. Any help/suggestions are greatly appreciated! Also, let me know if you need additional details to help diagnose the problem.

Head of the problem report

Process:               listmodel [6794]
Path:                  /Users/USER/Desktop/*/listmodel.app/Contents/MacOS/listmodel
Identifier:            com.yourcompany.listmodel
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        Qt Creator [6542]
Responsible:           Qt Creator [6542]
User ID:               501

Date/Time:             2015-06-02 19:56:23.064 -0400
OS Version:            Mac OS X 10.10.3 (14D136)
Report Version:        11
Anonymous UUID:        CA7E2107-3D4F-A7A7-372B-481ED0A7F257

Sleep/Wake UUID:       179C37EC-B84A-4BEE-A3EC-E9535903CE1D

Time Awake Since Boot: 6000 seconds
Time Since Wake:       2000 seconds

Crashed Thread:        8  QPythonWorker

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000008

Stack trace of the crashed thread

Thread 8 Crashed:: QPythonWorker
0   libpyothersideplugin.dylib      0x00000001161e4a9f PyObjectConverter::type(_object* const&) + 255
1   libpyothersideplugin.dylib      0x00000001161e5972 QVariant convert<_object*, QVariant, PyObjectConverter, QVariantConverter>(_object*) + 146
2   libpyothersideplugin.dylib      0x00000001161e9b42 QPythonPriv::call(_object*, QString, QVariant, QVariant*) + 306
3   libpyothersideplugin.dylib      0x00000001161df80b QPython::call_sync(QVariant, QVariant) + 971
4   libpyothersideplugin.dylib      0x00000001161e62c5 QPythonWorker::process(QVariant, QVariant, QJSValue*) + 69
5   libpyothersideplugin.dylib      0x00000001161ec4b6 QPythonWorker::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 390
6   org.qt-project.QtCore           0x000000010e8c73b3 QObject::event(QEvent*) + 755
7   org.qt-project.QtWidgets        0x000000010f28eddb QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
8   org.qt-project.QtWidgets        0x000000010f2920f8 QApplication::notify(QObject*, QEvent*) + 8136
9   org.qt-project.QtCore           0x000000010e89ca7b QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 971
10  org.qt-project.QtCore           0x000000010e8eedbb QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 59
11  org.qt-project.QtCore           0x000000010e89939d QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 381
12  org.qt-project.QtCore           0x000000010e68ea95 QThread::exec() + 117
13  org.qt-project.QtCore           0x000000010e692523 QThreadPrivate::start(void*) + 339
14  libsystem_pthread.dylib         0x00007fff8a639268 _pthread_body + 131
15  libsystem_pthread.dylib         0x00007fff8a6391e5 _pthread_start + 176
16  libsystem_pthread.dylib         0x00007fff8a63741d thread_start + 13
@thp
Copy link
Owner

thp commented Jun 3, 2015

I'm assuming you run from Git master or do you run a release?

@gdtroszak
Copy link
Author

Ah yes, sorry for forgetting that key piece of information! I'm running version 1.4.0.

Although I just tried running from master and got the same result.

@thp
Copy link
Owner

thp commented Jun 6, 2015

Have you tried installing Qt 5 from homebrew as well and see if that makes any difference?

@gdtroszak
Copy link
Author

I have tried a homebrewed Qt5 and got the same result.

I've been playing with this a bit more and have found that if I run the example using qmlscene it works just fine. However, if I try to recreate the example in a Qt Quick Application (by adding the qml and python files as resources), that's when I experience the issue above. If I comment out the py.call block or just return a string from the python function, everything runs just fine (I get a blank black box in an application window). I've had the same result on OS X, Ubuntu, and Windows 8.

Perhaps I'm creating the application incorrectly? It's just odd to me that it still runs when I return a string.

@Moguri
Copy link

Moguri commented Jun 9, 2015

I get a crash by creating a Qt Quick application in Qt Creator and using the following qml:

import QtQuick 2.4
import QtQuick.Window 2.2
import io.thp.pyotherside 1.5

Window {
    visible: true

    Python {
        id: python
        Component.onCompleted: {
            addImportPath(Qt.resolvedUrl('.'));
            importModule('editor', function () {
                call('editor.Crasher', [], function () {
                });
            });
        }
    }
}

And this editor.py:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pyotherside

class Crasher:
    def __init__(self):
        pass

Similarly, I don't get a crash if I instantiate an object in the module and call a method on the object that returns a string. Also, I do not get a crash when using qmlscene. The backtrace for the crashing thread:

0   QVariant convert<_object *, QVariant, PyObjectConverter, QVariantConverter>(_object *)          0x7fffd9fe4570  
1   QPythonPriv::call(_object *, QString, QVariant, QVariant *)         0x7fffd9fea44c  
2   QPython::call_sync(QVariant, QVariant)          0x7fffd9fdf8ea  
3   QPythonWorker::process(QVariant, QVariant, QJSValue *)          0x7fffd9fe71ca  
4   ??          0x7fffd9fed504  
5   QObject::event(QEvent *)            0x7ffff6375ae1  
6   QCoreApplication::notify(QObject *, QEvent *)           0x7ffff6344449  
7   QCoreApplication::notifyInternal(QObject *, QEvent *)           0x7ffff634457b  
8   QCoreApplicationPrivate::sendPostedEvents(QObject *, int, QThreadData *)            0x7ffff63466b7  
9   ??          0x7ffff639b8f3  
10  g_main_context_dispatch         0x7ffff32749fd  
11  ??          0x7ffff3274ce0  
12  g_main_context_iteration            0x7ffff3274d8c  
13  QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)          0x7ffff639bcff  
14  QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)         0x7ffff6341ffa  
15  QThread::exec()         0x7ffff61601a4  
16  ??          0x7ffff616508e  
17  start_thread            0x7ffff5b80354  
18  clone           0x7ffff5022bfd  

System Info:
OS: Arch Linux 64 bit (4.0.5 kernel)
Qt Version: 5.4.2
PyOtherSide version: master (2378495)

I don't know how much any of this information helps, but at least it's another data point. I can collect more information if needed.

@Moguri
Copy link

Moguri commented Jun 9, 2015

Also, a debug build (made using qmake CONFIG+=debug) does not seem to cause a crash.

@gdtroszak gdtroszak changed the title Thread Crashes on OS X Yosemite Thread Crashes in Qt Quick Applications Jun 9, 2015
@gdtroszak
Copy link
Author

I can confirm @Moguri's findings. However, both debug and release builds crash for me. I am also happy to collect more information.

@thp
Copy link
Owner

thp commented Jun 9, 2015

Thanks for all the detailed info, I should be able to reproduce it with this info. I haven't gotten around to do it, but it's on my TODO list. If anybody is faster and has the time to analyze and debug this, feel free to submit a pull request, otherwise I'll hopefully get around to it in a few days.

@dyreby
Copy link

dyreby commented Jun 9, 2015

I am also experiencing this issue under Windows using Qt Creator with Visual Studio 2013 (with the current master branch of pyotherside). It appears that the combination of returning a list from a python file that is located in a resource file is what triggers the crash. I am able to successfully run the listmodel example as a compiled Qt Quick application if I place the listmodel.py file in the final build directory so it is imported as a regular file. If the .py file is located in the .qrc resource file I am only able to return strings, ints, and floats. Any other return type (including None) triggers the crash.

I can provide more information or a stack trace if it will help. Also thanks for your work on pyotherside - it's a very powerful tool that is enabling us to do some really cool work.

@thp thp changed the title Thread Crashes in Qt Quick Applications Crash when python files are loaded from Qt Resources Jun 12, 2015
@thp
Copy link
Owner

thp commented Jun 12, 2015

I could reproduce this issue here. It only happens when putting the files into Qt Resources. As a workaround, don't use the Qt resources feature, but just put the files into the working directory.

thp added a commit that referenced this issue Jun 13, 2015
@thp
Copy link
Owner

thp commented Jun 13, 2015

I could not reproduce this with the test case now in Git and Qt 5.2.1 / Python 3.4.0, will try with a newer Qt version.

@thp thp changed the title Crash when python files are loaded from Qt Resources Crash with Qt 5.4.2 when .py files are loaded from Qt Resources Jun 13, 2015
@thp thp closed this as completed in 6d7f526 Jun 13, 2015
@thp
Copy link
Owner

thp commented Jun 13, 2015

This should be fixed with the latest commit in the Git master branch. See 6d7f526 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants