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

[Bug]: Qt6 QProcess fails to create process for Linux kernel >= 5 #20354

Closed
knyipab opened this issue May 29, 2024 · 7 comments · Fixed by #20374
Closed

[Bug]: Qt6 QProcess fails to create process for Linux kernel >= 5 #20354

knyipab opened this issue May 29, 2024 · 7 comments · Fixed by #20374

Comments

@knyipab
Copy link
Contributor

knyipab commented May 29, 2024

Most things in this PR shocut app works well, except that the export job does not work.,, stuck at finite time "--:--:--". You may try the builds in the PR #20353 or this action: https://github.com/knyipab/termux-packages/actions/runs/9290613878

After use the program to export file, the only useful log from terminal is below.

[Debug  ] <MeltJob::start> "/data/data/com.termux/files/usr/bin/melt-7 -verbose -progress2 -abort xml:%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fusr%2Ftmp%2Fshotcut-jnXVRh.mlt" 

Indeed, if I run that command /data/data/com.termux/files/usr/bin/melt-7 -verbose -progress2 -abort xml:%2Fdata%2Fdata%2Fcom.termux%2Ffiles%2Fusr%2Ftmp%2Fshotcut-jnXVRh.mlt, it works well and output the intended video.

That line of log corresponds to this line of code in MeltJob::start(). That method should ultimately call QProcess::start() at this line. So I suspect that QProcess does not function. I have no proof and nothing more in the log is helpful.

@knyipab knyipab changed the title QProcess seems not work well for shotcut app Qt6 QProcess seems not work well for shotcut app May 30, 2024
@Biswa96
Copy link
Member

Biswa96 commented May 30, 2024

Does strace provide any hint?

@knyipab
Copy link
Contributor Author

knyipab commented May 30, 2024

Don't have experience with strace but it seems to fail to create child process.

clone(child_stack=0x7ffdb65530, flags=CLONE_VM|CLONE_PIDFD|CLONE_VFORK|SIGCHLD, parent_tid=NULL) = -1 EFAULT (Bad address)

strace log: shortcut_excerpt.log

@knyipab knyipab changed the title Qt6 QProcess seems not work well for shotcut app Qt6 QProcess does not work May 30, 2024
@knyipab knyipab changed the title Qt6 QProcess does not work Qt6 QProcess fails to create process May 30, 2024
@knyipab
Copy link
Contributor Author

knyipab commented May 30, 2024

A simple Qt6 example (generated by ChatGPT) fails to execute command with QProcess. strace show similar error in clone syscall.

g++ -o qprocess qprocess.cpp -lQt6Core -I"$PREFIX"/include/qt6 -I"$PREFIX"/include/qt6/QtCore

qprocess.cpp

#include <QCoreApplication>
#include <QProcess>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    QProcess process;
    process.start("ls", QStringList() << "-l");

    if (process.waitForStarted() && process.waitForFinished()) {
        QByteArray output = process.readAllStandardOutput();
        qDebug() << output;
    } else {
        qDebug() << "Failed to start or execute command.";
    }

    return app.exec();
}

Qt5

This same example compiled with qt5 works

g++ -o qprocess qprocess.cpp -lQt5Core -I"$PREFIX"/include -I"$PREFIX"/include/QtCore

@knyipab knyipab changed the title Qt6 QProcess fails to create process [Bug]: Qt6 QProcess fails to create process May 30, 2024
@Biswa96
Copy link
Member

Biswa96 commented May 30, 2024

That example program worked in my PC (x86_64) and in my phone (aarch64) without any error.

execve("/data/data/com.termux/files/usr/bin/test", ["test"], 0x7fd1e78830 /* 54 vars */) = 0

@knyipab
Copy link
Contributor Author

knyipab commented May 30, 2024

When it is without strace, does that example program print something similar to ls -l on your device? On my phone, the qt6 build prints Failed to start or execute command. while qt5 build prints something similar to ls -l.

As for strace syscall clone results,

  • qt6 build shows clone(child_stack=0x7fed797470, flags=CLONE_VM|CLONE_PIDFD|CLONE_VFORK|SIGCHLD, parent_tid=NULL) = -1 EFAULT (Bad address)
  • qt5 build shows clone(child_stack=NULL, flags=CLONE_PIDFD|SIGCHLD, parent_tid=[12]) = 19309

Do you see similar thing for qt6 build? If not, it might be vendor-specific.

@Biswa96
Copy link
Member

Biswa96 commented May 30, 2024

When it is without strace, does that example program print something similar to ls -l on your device?

Yes.

@knyipab
Copy link
Contributor Author

knyipab commented May 30, 2024

It seems to be system_vforkfd introduced in Qt6.4 (this commit). I think for us, we should patch it to use the old system_forkfd instead.

FYI, this problem seems to occur in runtime depending on the kernel version:

Device Arch Android Linux Build strace clone flags success?
Emulated x86_64 14 6.1.23 Qt6 CLONE_VM|CLONE_PIDFD|CLONE_VFORK|SIGCHLD no
Emulated x86_64 14 6.1.23 Qt5 CLONE_PIDFD|SIGCHLD yes
Emulated x86_64 13 5.15.41 Qt6 CLONE_VM|CLONE_PIDFD|CLONE_VFORK|SIGCHLD no
Emulated x86_64 13 5.15.41 Qt5 CLONE_PIDFD|SIGCHLD yes
Samsung Fold5 aarch64 13 5.15.41 Qt6 CLONE_VM|CLONE_PIDFD|CLONE_VFORK|SIGCHLD no
Samsung Fold5 aarch64 13 5.15.41 Qt5 CLONE_PIDFD|SIGCHLD yes
Emulated x86 11 5.4.61 Qt6 CLONE_VM|CLONE_PIDFD|CLONE_VFORK|SIGCHLD no
Emulated x86 11 5.4.61 Qt5 CLONE_PIDFD|SIGCHLD yes
Pixel 4a aarch64 13 4.14.302 Qt6 CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD yes
Pixel 4a aarch64 13 4.14.302 Qt5 CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD yes
Emulated x86 9 4.4.124 Qt6 CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD yes
Emulated x86 9 4.4.124 Qt5 CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD yes

@knyipab knyipab changed the title [Bug]: Qt6 QProcess fails to create process [Bug]: Qt6 QProcess fails to create process for Linux kernel > 4 May 30, 2024
@knyipab knyipab changed the title [Bug]: Qt6 QProcess fails to create process for Linux kernel > 4 [Bug]: Qt6 QProcess fails to create process for Linux kernel >= 5 May 30, 2024
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

Successfully merging a pull request may close this issue.

2 participants