diff options
author | Michal Klocek <michal.klocek@qt.io> | 2022-06-22 17:16:54 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-16 07:50:46 +0000 |
commit | 9669a4cdf302d7791d1888702cb2b5731a656fa6 (patch) | |
tree | b9a238da8e566cfc3d070f6192bb3fecd2be29cb | |
parent | 57b5982690399d0b5713e8129707c3ffc45fe0a1 (diff) |
Fix single process crash when proxy pac is used
Using proxy v8 resolver ends up in race condition
when render thread tries to evaluate extension handle
and v8 proxy resolver evaluates proxy pac script.
Disable v8 proxy resolver for single process mode.
Issue tracked upstream http://crbug.com/474654
Modify the unit test to catch the crash case, the test
loads now network resource but it does not matter
as we do not check for failure or success.
Fixes: QTBUG-104436
Change-Id: Id3221d1b8b3896f0ced3d0cd7cb9d9eceeb929cc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 1b6633d1ce86eaf43b750a03a785793512e487ed)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/core/net/system_network_context_manager.cpp | 10 | ||||
-rw-r--r-- | tests/auto/widgets/proxypac/CMakeLists.txt | 22 | ||||
-rw-r--r-- | tests/auto/widgets/proxypac/proxy.pac | 2 | ||||
-rw-r--r-- | tests/auto/widgets/proxypac/tst_proxypac.cpp | 14 |
4 files changed, 39 insertions, 9 deletions
diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp index 7e5de7d2b..3ee06b7c9 100644 --- a/src/core/net/system_network_context_manager.cpp +++ b/src/core/net/system_network_context_manager.cpp @@ -267,7 +267,15 @@ void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams(network:: // respect prefs::kEnableReferrers from the appropriate pref store. network_context_params->enable_referrers = false; - network_context_params->proxy_resolver_factory = ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver(); + const base::CommandLine& command_line = + *base::CommandLine::ForCurrentProcess(); + + if (command_line.HasSwitch(switches::kSingleProcess)) { + LOG(ERROR) << "Cannot use V8 Proxy resolver in single process mode."; + } else { + network_context_params->proxy_resolver_factory = + ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver(); + } // Use the SystemNetworkContextManager to populate and update SSL // configuration. The SystemNetworkContextManager is owned by the diff --git a/tests/auto/widgets/proxypac/CMakeLists.txt b/tests/auto/widgets/proxypac/CMakeLists.txt index 1dd2c8bec..d3ddfd0c5 100644 --- a/tests/auto/widgets/proxypac/CMakeLists.txt +++ b/tests/auto/widgets/proxypac/CMakeLists.txt @@ -21,6 +21,22 @@ set_tests_properties(tst_proxypac_file PROPERTIES ENVIRONMENT QTWEBENGINE_CHROMIUM_FLAGS=${fileEnvArg} ) +if(NOT (LINUX AND CMAKE_CROSSCOMPILING)) + set(fileEnvArg "--single-process ${fileEnvArg}") + + qt_internal_add_test(tst_proxypac_single_process + SOURCES + tst_proxypac.cpp + LIBRARIES + Qt::WebEngineCore + Test::HttpServer + ) + + set_tests_properties(tst_proxypac_single_process PROPERTIES + ENVIRONMENT QTWEBENGINE_CHROMIUM_FLAGS=${fileEnvArg} + ) +endif() + qt_internal_add_test(tst_proxypac_qrc SOURCES tst_proxypac.cpp @@ -40,8 +56,6 @@ set_tests_properties(tst_proxypac_qrc PROPERTIES ) qt_internal_add_resource(tst_proxypac_qrc "proxypac" - PREFIX - "/" - FILES - "proxy.pac" + PREFIX "/" + FILES "proxy.pac" ) diff --git a/tests/auto/widgets/proxypac/proxy.pac b/tests/auto/widgets/proxypac/proxy.pac index 1d29847b9..966c37ba5 100644 --- a/tests/auto/widgets/proxypac/proxy.pac +++ b/tests/auto/widgets/proxypac/proxy.pac @@ -2,6 +2,6 @@ function FindProxyForURL(url, host) { if (shExpMatch(host, "*.proxy1.com")) return "PROXY localhost:5551"; if (shExpMatch(host, "*.proxy2.com")) return "PROXY localhost:5552"; - return "PROXY proxy.url:8080"; + return "DIRECT"; } diff --git a/tests/auto/widgets/proxypac/tst_proxypac.cpp b/tests/auto/widgets/proxypac/tst_proxypac.cpp index 8667af24a..d372f77fa 100644 --- a/tests/auto/widgets/proxypac/tst_proxypac.cpp +++ b/tests/auto/widgets/proxypac/tst_proxypac.cpp @@ -8,7 +8,6 @@ #include <QWebEnginePage> #include <QNetworkProxy> - class tst_ProxyPac : public QObject { Q_OBJECT public: @@ -39,11 +38,20 @@ void tst_ProxyPac::proxypac() QWebEngineProfile profile; QWebEnginePage page(&profile); + + const bool v8_proxy_resolver_enabled = !fromEnv.contains("--single-process"); page.load(QUrl("http://test.proxy1.com")); - QTRY_COMPARE(proxySpy1.count() >= 1, true); + QTRY_COMPARE(proxySpy1.count() >= 1, v8_proxy_resolver_enabled); QVERIFY(proxySpy2.count() == 0); page.load(QUrl("http://test.proxy2.com")); - QTRY_COMPARE(proxySpy2.count() >= 1 , true); + QTRY_COMPARE(proxySpy2.count() >= 1, v8_proxy_resolver_enabled); + + // check for crash + QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished); + page.load(QUrl("https://contribute.qt-project.org")); + + QTRY_VERIFY_WITH_TIMEOUT(!spyFinished.isEmpty(), 100000); + } #include "tst_proxypac.moc" |