[webkit-changes] [WebKit/WebKit] 4b27f1: [WPE][GTK] WebProcess crashes at the end of every ...

Vitaly Dyachkov noreply at github.com
Tue Jul 18 07:43:25 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4b27f17f5ade44bc02f5d8707c8140a762bb9253
      https://github.com/WebKit/WebKit/commit/4b27f17f5ade44bc02f5d8707c8140a762bb9253
  Author: Vitaly Dyachkov <vitaly at igalia.com>
  Date:   2023-07-18 (Tue, 18 Jul 2023)

  Changed paths:
    M Tools/TestWebKitAPI/Tests/WebKitGLib/DOMElementTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGLib/EditorTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGLib/WebProcessTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGLib/WebProcessTest.h
    M Tools/TestWebKitAPI/Tests/WebKitGtk/AutocleanupsTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGtk/DOMClientRectTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGtk/DOMNodeFilterTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGtk/DOMNodeTest.cpp
    M Tools/TestWebKitAPI/Tests/WebKitGtk/DOMXPathNSResolverTest.cpp

  Log Message:
  -----------
  [WPE][GTK] WebProcess crashes at the end of every GLib API test
https://bugs.webkit.org/show_bug.cgi?id=259303

Reviewed by Michael Catanzaro.

To run web process API tests we need to be able to execute code in
the web process. This is done by using web process extensions.

`WebProcessTest.cpp ` is a base class that implements the initialization
of a web process extension. This class also provides an API for
asserting that the `GObject` objects allocated in the web process during
test execution are deleted at the end of the test.

These `GObject` objects are stored in a static `HashSet`
`s_watchedObjects`. When the web process is terminating
`static void __attribute__((destructor)) checkLeaksAtExit()`
is called to verify that `s_watchedObjects` is empty, meaning
no objects were leaked.

The problem is that static variable destructors are invoking *before*
any `__attribute__((destructor))` functions. So by the time
`checkLeaksAtExit` is called, `s_watchedObjects` is already deallocated,
leading the web process to crash.

Because the web process extension modules we need for some tests are
located in the default directory, there are being loaded with every
API test. So we got the crash even if we don't run a web process test.

The solution to this problem is to wrap the watched objects hash set
into a static class and check for leaks in its destructor, before the
hash set is deallocated.

* Tools/TestWebKitAPI/Tests/WebKitGLib/DOMElementTest.cpp:
(DOMElementTest::testAutoFill):
* Tools/TestWebKitAPI/Tests/WebKitGLib/EditorTest.cpp:
(WebKitWebEditorTest::testSelectionChanged):
* Tools/TestWebKitAPI/Tests/WebKitGLib/FrameTest.cpp:
(WebKitFrameTest::testJavaScriptContext):
(WebKitFrameTest::testJavaScriptValues):
(WebKitFrameTest::testSubframe):
* Tools/TestWebKitAPI/Tests/WebKitGLib/WebProcessTest.cpp:
(runTest):
(webProcessTestRunnerFinalize):
(windowObjectClearedCallback):
(webkit_web_extension_initialize):
(checkLeaks): Deleted.
(WebProcessTest::assertObjectIsDeletedWhenTestFinishes): Deleted.
(checkLeaksAtExit): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitGLib/WebProcessTest.h:
(Watcher::~Watcher):
(Watcher::assertObjectIsDeletedWhenTestFinishes):
(Watcher::checkLeaks):
* Tools/TestWebKitAPI/Tests/WebKitGtk/AutocleanupsTest.cpp:
(AutocleanupsTest::testWebProcessAutocleanups):
* Tools/TestWebKitAPI/Tests/WebKitGtk/DOMClientRectTest.cpp:
(WebKitDOMClientRectTest::testDivBoundingClientRectPosition):
(WebKitDOMClientRectTest::testDivClientRectsPositionAndLength):
* Tools/TestWebKitAPI/Tests/WebKitGtk/DOMNodeFilterTest.cpp:
(WebKitDOMNodeFilterTest::testTreeWalker):
(WebKitDOMNodeFilterTest::testNodeIterator):
* Tools/TestWebKitAPI/Tests/WebKitGtk/DOMNodeTest.cpp:
(WebKitDOMNodeTest::testHierarchyNavigation):
(WebKitDOMNodeTest::testInsertion):
(WebKitDOMNodeTest::testTagNamesNodeList):
(WebKitDOMNodeTest::testTagNamesHTMLCollection):
(WebKitDOMNodeTest::testDOMCache):
* Tools/TestWebKitAPI/Tests/WebKitGtk/DOMXPathNSResolverTest.cpp:
(WebKitDOMXPathNSResolverTest::evaluateFooChildTextAndCheckResult):
(WebKitDOMXPathNSResolverTest::testXPathNSResolverNative):
(WebKitDOMXPathNSResolverTest::testXPathNSResolverCustom):

Canonical link: https://commits.webkit.org/266127@main




More information about the webkit-changes mailing list