From 2ed99ff5ca338ac02f71c347b1449d4662e6c221 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 14 Sep 2020 18:00:47 +0200 Subject: [PATCH] Make usage of forkfd_pidfd in QProcess a configurable feature Our CI cross-compiling arm qemu builds have issues in tests that use QProcess, due to user-space qemu seemingly not supporting pidfds properly. Add a 'forkfd_pidfd' configure.json feature, which can be manually disabled when configuring Qt, causing QProcess to do a regular fork instead of using the new pidfd kernel feature. This will help us avoid the regression of multiple tests failing on the new Ubuntu 20.04 CI host images when they are run via qemu. Task-number: QTBUG-86285 Task-number: QTBUG-86187 Task-number: QTBUG-86198 Change-Id: Ib2209d7e95126e0fb738bf59e39070d5a62c482f Reviewed-by: Thiago Macieira --- src/corelib/.prev_configure.cmake | 8 ++++++++ src/corelib/configure.cmake | 8 ++++++++ src/corelib/configure.json | 12 +++++++++++- src/corelib/io/qprocess_unix.cpp | 6 ++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/corelib/.prev_configure.cmake b/src/corelib/.prev_configure.cmake index 6619762a29..b410879c45 100644 --- a/src/corelib/.prev_configure.cmake +++ b/src/corelib/.prev_configure.cmake @@ -929,6 +929,10 @@ qt_feature("etw" PRIVATE ENABLE INPUT_trace STREQUAL 'etw' OR ( INPUT_trace STREQUAL 'yes' AND WIN32 ) DISABLE INPUT_trace STREQUAL 'lttng' OR INPUT_trace STREQUAL 'no' ) +qt_feature("forkfd_pidfd" PRIVATE + LABEL "pidfd support in forkfd" + CONDITION LINUX +) qt_feature("win32_system_libs" LABEL "Windows System Libraries" CONDITION WIN32 AND libs.advapi32 AND libs.gdi32 AND libs.kernel32 AND libs.netapi32 AND libs.ole32 AND libs.shell32 AND libs.uuid AND libs.user32 AND libs.winmm AND libs.ws2_32 OR FIXME @@ -966,6 +970,10 @@ qt_configure_add_summary_entry( ) qt_configure_add_summary_entry(ARGS "pcre2") qt_configure_add_summary_entry(ARGS "system-pcre2") +qt_configure_add_summary_entry( + ARGS "forkfd_pidfd" + CONDITION LINUX +) qt_configure_end_summary_section() # end of "Qt Core" section qt_configure_add_report_entry( TYPE NOTE diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index a6aecd2ae1..1288666a3d 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -935,6 +935,10 @@ qt_feature("etw" PRIVATE ENABLE INPUT_trace STREQUAL 'etw' OR ( INPUT_trace STREQUAL 'yes' AND WIN32 ) DISABLE INPUT_trace STREQUAL 'lttng' OR INPUT_trace STREQUAL 'no' ) +qt_feature("forkfd_pidfd" PRIVATE + LABEL "CLONE_PIDFD support in forkfd" + CONDITION LINUX +) qt_feature("win32_system_libs" LABEL "Windows System Libraries" CONDITION WIN32 AND libs.advapi32 AND libs.gdi32 AND libs.kernel32 AND libs.netapi32 AND libs.ole32 AND libs.shell32 AND libs.uuid AND libs.user32 AND libs.winmm AND libs.ws2_32 OR FIXME @@ -972,6 +976,10 @@ qt_configure_add_summary_entry( ) qt_configure_add_summary_entry(ARGS "pcre2") qt_configure_add_summary_entry(ARGS "system-pcre2") +qt_configure_add_summary_entry( + ARGS "forkfd_pidfd" + CONDITION LINUX +) qt_configure_end_summary_section() # end of "Qt Core" section qt_configure_add_report_entry( TYPE NOTE diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 8e2d4e859d..27fff51a0f 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -1013,6 +1013,11 @@ "condition": "config.win32", "output": [ "privateFeature" ] }, + "forkfd_pidfd": { + "label": "CLONE_PIDFD support in forkfd", + "condition": "config.linux", + "output": [ "privateFeature" ] + }, "win32_system_libs": { "label": "Windows System Libraries", "condition": "config.win32 && libs.advapi32 && libs.gdi32 && libs.kernel32 && libs.netapi32 && libs.ole32 && libs.shell32 && libs.uuid && libs.user32 && libs.winmm && libs.ws2_32" @@ -1094,7 +1099,12 @@ Note that this is required for plugin loading. Qt GUI needs QPA plugins for basi "condition": "config.qnx" }, "pcre2", - "system-pcre2" + "system-pcre2", + { + "type": "feature", + "args": "forkfd_pidfd", + "condition": "config.linux" + } ] } ] diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index f14e78f94e..5fce848c2c 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -461,6 +461,12 @@ void QProcessPrivate::startProcess() int ffdflags = FFD_CLOEXEC; if (childProcessModifier) ffdflags |= FFD_USE_FORK; + + // QTBUG-86285 +#if !QT_CONFIG(forkfd_pidfd) + ffdflags |= FFD_USE_FORK; +#endif + pid_t childPid; forkfd = ::forkfd(ffdflags , &childPid); int lastForkErrno = errno;