QuasarApp / CQtDeployer

This project is used to deploy applications written using QML, qt or other С / С++ frameworks.
https://quasarapp.ddns.net:3031/docs/QuasarApp/CQtDeployer/latest/
GNU Lesser General Public License v3.0
570 stars 89 forks source link

CQtDeployer: 1.6.2360.9dc5a16: crash while deploying Qt6 app #821

Closed marcelpetrick closed 1 month ago

marcelpetrick commented 1 month ago

I had previously a Qt 5.15 application, which was ported to Qt 6.5. Now the deployment fails. CQtDeployer is still the same. I have adapted of course the deployment parameters.

The idea is just to collect for a proper C++/QML-app all needed artifacts.

Any idea, what could trigger this crash? Thank you in advance.

ps. Enabling verbose was not really increasing the output why the crash happens.

ps@p118vm:~/DistributionKit$ cqtdeployer v
Info: Print info ...
CQtDeployer: 1.6.2360.9dc5a16 *** Cool Core (snap) ***
Qt: 6.6.0
ps@p118vm:~/DistributionKit$ time cqtdeployer --verbose 3 -bin /home/ps/Documents/p118/projects/p118-bora.tfs/03_SourceCode/hmi/build/Clone_of_Desktop_Qt_6_5_5_GCC_64bit-Debug/src/P118 -qmake /home/ps/Documents/p118/Qt/6.5.5/gcc_64/bin/qmake -qmlDir /home/ps/Documents/p118/projects/p118-bora.tfs/03_SourceCode/hmi/src/qml/ -targetDir /home/ps/DistributionKit/P118 clear
Info: Deploy ...
Info: clear old data
Info: Clear start!
Info: copy :/home/ps/Documents/p118/projects/p118-bora.tfs/03_SourceCode/hmi/build/Clone_of_Desktop_Qt_6_5_5_GCC_64bit-Debug/src/P118
/snap/cqtdeployer/279/CQtDeployer.sh: line 37:  5123 Segmentation fault      (core dumped) "$BASE_DIR/bin/CQtDeployer" "$@"

real    0m2,042s
user    0m0,858s
sys     0m0,526s
ps@p118vm:~/DistributionKit$ ^C

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

EndrII commented 1 month ago

Hi can you show me your deployment command ?

marcelpetrick commented 1 month ago

Hello @EndrII, sorry for the brief report last evening, but I was in a hurry after trying out to fix it on my side.

cqtdeployer --verbose 3 -bin /home/ps/Documents/p118/projects/p118-bora.tfs/03_SourceCode/hmi/build/Clone_of_Desktop_Qt_6_5_5_GCC_64bit-Debug/src/P118 -qmake /home/ps/Documents/p118/Qt/6.5.5/gcc_64/bin/qmake -qmlDir /home/ps/Documents/p118/projects/p118-bora.tfs/03_SourceCode/hmi/src/qml/ -targetDir /home/ps/DistributionKit/P118 clear As seen above.

It was working before we ported the app from Qt5 to 6. Of course the paths for qmake and the bin were adapted, but else it does nothing fancy.

Do you have any similar reports or idea why this could crash?

EndrII commented 1 month ago

i need more time to found issue, this is looks as trouble int CQtDeployer distribution package... or host filesystem. but is supper strength that its crashed only on qt6 ...

Can you show me verbose log - its needed to check where is crashed -verbose 3

waelkarman commented 1 month ago

Hi @EndrII That's the output Info: Deploy ... Info: clear old data Info: Clear start! Info: copy :/home/ps/Documents/p118/projects/p118-bora.tfs/03_SourceCode/hmi/build/Clone_of_Desktop_Qt_6_5_5_GCC_64bit-Debug/src/P118 /snap/cqtdeployer/279/CQtDeployer.sh: line 37: 4849 Segmentation fault (core dumped) "$BASE_DIR/bin/CQtDeployer" "$@"

EndrII commented 1 month ago

Oh) , it's not a verbose log, please use -verbose 3 instead --verbose 3 i see you insert two - symbols before verbose. Use only one, please )

waelkarman commented 1 month ago

I already used two hypens

waelkarman commented 1 month ago

@EndrII Looks that is failing getting the qml files. From my understanding the program is reading all qml files import and seek for it in the file system.

extracter.cpp if (qmlScaner && !qmlScaner->scan(plugins, info.absoluteFilePath())) { QuasarAppUtils::Params::log("Failed to run qml scanner", QuasarAppUtils::Error); continue; }

With a custom import this process is failing: image

com/bora/foodpreferencecontroller is not a part of Qt6.5.5. It's a custom import that have no path in Qt/6.5.5/gcc_64/qml to which he is trying to access => Segmentation Fault

waelkarman commented 1 month ago

@EndrII Commenting the scan method in extractor.cpp no segmentation fault is showing up. So most likely the issue is happening there.

The issue seems to be in the qmlqt6.cpp file in the function: [58] bool QMLQt6::extractImportsFromDir(const QString &path, bool recursive)

in fact commenting the line 217 of the same file gets no segmentation fault

EndrII commented 1 month ago

How many times cqtdeployer print message with path ? because i see here stack overflow ... on recursive search dependencies ...

waelkarman commented 1 month ago

Several. Looks not the existance of path itself but something happening in the recursive calls.

bool QMLQt6::extractImportsFromDir(const QString &pt, bool recursive) {
    QuasarAppUtils::Params::log( "ENTER POINT" ,QuasarAppUtils::Info);
    QuasarAppUtils::Params::log( "PATH" ,QuasarAppUtils::Info);
    QString path = pt;

    QuasarAppUtils::Params::log( path ,QuasarAppUtils::Info);
    QDir dir(path);

    if (!dir.isReadable()) {
        return false;
    }

    auto files = dir.entryInfoList(QStringList() << "*.qml" << "*.QML", QDir::Files);
    auto qmlmodule = dir.entryInfoList(QStringList() << "qmldir", QDir::Files);

    auto dirs = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs);

    for (const auto &info: files) {
        auto imports = extractImportsFromFile(info.absoluteFilePath());
        for (const auto &import : std::as_const(imports)) {
            if (!_imports.contains(import)) {
                _imports.insert(import);
                QuasarAppUtils::Params::log( "IMPORT:" ,QuasarAppUtils::Info);
                QuasarAppUtils::Params::log( import ,QuasarAppUtils::Info);
                extractImportsFromDir(getPathFromImport(import), false);
            }
        }
    }

    for (const auto& module: std::as_const(qmlmodule)) {
        QStringList imports = extractImportsFromQmlModule(module.absoluteFilePath());
        imports += extractImportsFromFile(module.absoluteFilePath());

        for (const auto &import : std::as_const(imports)) {
            if (!_imports.contains(import)) {
                _imports.insert(import);
                extractImportsFromDir(getPathFromImport(import), false);
            }
        }
    }

    // task https://github.com/QuasarApp/CQtDeployer/issues/600
    // There are no import lines for the qt models module in Qt 6.1, but this module is required for all qml applications.
    auto importQtQml = "QtQml";
    if (!_imports.contains(importQtQml)) {
        _imports.insert(importQtQml);
        extractImportsFromDir(getPathFromImport(importQtQml), false);
    }

    if (recursive) {
        for (const auto &info: dirs) {
            extractImportsFromDir(info.absoluteFilePath(), recursive);
        }
    }
    QuasarAppUtils::Params::log( "RETURN CHECKPOINT" ,QuasarAppUtils::Info);
    return true;
}

OUTPUT:

output.txt

EndrII commented 1 month ago

Hm... can you try to deploy your project using deb version of cqtdeployer? Or using snap but on other Ubuntu (not 18.04)? I think trouble in file system access between core22 and Ubuntu 18.04. It may bug of snap.

So to fix it, I need to deploy cqtdeployer based on other core package... If i right, the deb version of cqtdeployer will work correctly.

waelkarman commented 1 month ago

I'm using a VM of Kubuntu 22.04.4 image I'll try with the deb version. . . I was using the one downloaded with snap. I compiled from sources just to debug.

waelkarman commented 1 month ago

image

Same Issue. In photo also the packet that I installed.

waelkarman commented 1 month ago

@EndrII @marcelpetrick the segmentation fault issue was coming up because inside one of the parsed qml files was there importConfirmationPopup.open() adding in the filter a space after the import statement avoids these "fake import" to be catched.

image

renaming importConfirmationPopup.open() as well as add a space in the filter (see PR-822) solves the issue.

EndrII commented 1 month ago

Thank you ) tests is passed, i will publish fixed version.

waelkarman commented 1 month ago

Thanks for your support :)

EndrII commented 1 month ago

@waelkarman please update your cqtdeployer and check your fixes. If all is good, please close this issue. Thank you for your help!

waelkarman commented 1 month ago

@EndrII I can't close the issue, @marcelpetrick could you please close it? It's tested.

EndrII commented 1 month ago

@marcelpetrick i close this issue, if its still not fixed for you just reopen it.