Bug 223965 - [GTK][WPE] Several http/tests/contentextensions tests crash at TestController::configureContentExtensionForTest()
Summary: [GTK][WPE] Several http/tests/contentextensions tests crash at TestController...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-30 16:29 PDT by Carlos Alberto Lopez Perez
Modified: 2021-04-01 11:40 PDT (History)
8 users (show)

See Also:


Attachments
full crash log with threads (58.58 KB, text/plain)
2021-03-30 16:30 PDT, Carlos Alberto Lopez Perez
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Alberto Lopez Perez 2021-03-30 16:29:38 PDT
It seems we have a regression on GTK and WPE ports after r275204. The following tests crash now:

Regressions: Unexpected crashes (5)
  http/tests/contentextensions/block-cookies-in-csp-report.py [ Crash ]
  http/tests/contentextensions/block-csp-report.py [ Crash ]
  http/tests/contentextensions/block-everything-unless-domain-redirect.py [ Crash ]
  http/tests/contentextensions/hide-on-csp-report.py [ Crash ]
  http/tests/contentextensions/main-resource-redirect-blocked.py [ Crash ]



I have debugged this and the issue is triggered by the new python scripts.
The HTTP headers they output is different than the previous PHP scripts


See this example with http/tests/contentextensions/main-resource-redirect-blocked.py 

$ printf 'GET /contentextensions/main-resource-redirect-blocked.php HTTP/1.1\r\nHost: localhost\r\n\r\n' | nc localhost 8000
HTTP/1.0 302 Found
Date: Tue, 30 Mar 2021 23:06:50 GMT
Server: Apache/2.4.38 (Debian)
X-Powered-By: PHP/7.0.30-0+deb9u1
Location: resources/main-resource-redirect-blocked-target.html
Content-Length: 0
Connection: close
Content-Type: text/html

$ printf 'GET /contentextensions/main-resource-redirect-blocked.py HTTP/1.1\r\nHost: localhost\r\n\r\n' | nc localhost 8000
HTTP/1.1 302 Found
Date: Tue, 30 Mar 2021 23:06:52 GMT
Server: Apache/2.4.38 (Debian)
Location: resources/main-resource-redirect-blocked-target.html
Transfer-Encoding: chunked
Content-Type: text/html

0


With the python version it prints different headers (notice the HTTP/1.0 vs HTTP/1.1). It also prints a 0 at the end. It misses the content-length fields and it also doesn't exit intermediately: the connection gets stuck for a few seconds.


I have been trying to modify the main-resource-redirect-blocked.py version to print the same headers than the previous PHP version but so far I had no much luck. The crash is still happening.


The crash log (for http/tests/contentextensions/main-resource-redirect-blocked.py) says this:

Thread 1 (Thread 0x7fb7f7a4ca00 (LWP 32687)):
#0  WTFCrash() () at ../../Source/WTF/wtf/Assertions.cpp:295
#1  0x00005623c645ce18 in CRASH_WITH_INFO(...) () at DerivedSources/ForwardingHeaders/wtf/Assertions.h:713
#2  0x00005623c646a5ae in WTR::TestController::configureContentExtensionForTest(WTR::TestInvocation const&) (this=0x7ffe006e4ca0, test=...) at ../../Tools/WebKitTestRunner/TestController.cpp:1423
#3  0x00005623c6469ec3 in WTR::TestController::configureViewForTest(WTR::TestInvocation const&) (this=0x7ffe006e4ca0, test=...) at ../../Tools/WebKitTestRunner/TestController.cpp:1339
#4  0x00005623c649cd91 in WTR::TestInvocation::invoke() (this=0x7fb7f01e62c0) at ../../Tools/WebKitTestRunner/TestInvocation.cpp:144
#5  0x00005623c646ab72 in WTR::TestController::runTest(char const*) (this=0x7ffe006e4ca0, inputLine=0x7ffe006e4400 "http://127.0.0.1:8000/contentextensions/main-resource-redirect-blocked.py'--absolutePath'/app/webkit/LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked.py'--timeout'30000") at ../../Tools/WebKitTestRunner/TestController.cpp:1493
#6  0x00005623c646ad89 in WTR::TestController::runTestingServerLoop() (this=0x7ffe006e4ca0) at ../../Tools/WebKitTestRunner/TestController.cpp:1539
#7  0x00005623c646adde in WTR::TestController::run() (this=0x7ffe006e4ca0) at ../../Tools/WebKitTestRunner/TestController.cpp:1547
#8  0x00005623c646551e in WTR::TestController::TestController(int, char const**) (this=0x7ffe006e4ca0, argc=2, argv=0x7ffe006e5148) at ../../Tools/WebKitTestRunner/TestController.cpp:194
#9  0x00005623c64ca049 in main(int, char**) (argc=2, argv=0x7ffe006e5148) at ../../Tools/WebKitTestRunner/gtk/main.cpp:45

STDERR: 
STDERR: warning: the debug information found in "/usr/lib/debug//usr/lib/x86_64-linux-gnu/libicudata.so.67.1.debug" does not match "/usr/lib/x86_64-linux-gnu/libicudata.so.67" (CRC mismatch).
STDERR: 
STDERR: 
STDERR: warning: the debug information found in "/usr/lib/debug//usr/lib/x86_64-linux-gnu/libicudata.so.67.1.debug" does not match "/usr/lib/x86_64-linux-gnu/libicudata.so.67" (CRC mismatch).
STDERR: 
STDERR: 
STDERR: warning: the debug information found in "/usr/lib/debug//usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0.debug" does not match "/usr/lib/x86_64-linux-gnu/libX11-xcb.so.1" (CRC mismatch).
STDERR: 
STDERR: 
STDERR: warning: the debug information found in "/usr/lib/debug//usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0.debug" does not match "/usr/lib/x86_64-linux-gnu/libX11-xcb.so.1" (CRC mismatch).
STDERR: 
STDERR: ASSERTION FAILED: context.status == kWKUserContentExtensionStoreSuccess
STDERR: ../../Tools/WebKitTestRunner/TestController.cpp(1423) : void WTR::TestController::configureContentExtensionForTest(const WTR::TestInvocation&)
STDERR: 1   0x7fb7fec7c1c7 WTFCrash
STDERR: 2   0x5623c645ce18 /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xe7e18) [0x5623c645ce18]
STDERR: 3   0x5623c646a5ae /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xf55ae) [0x5623c646a5ae]
STDERR: 4   0x5623c6469ec3 /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xf4ec3) [0x5623c6469ec3]
STDERR: 5   0x5623c649cd91 /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0x127d91) [0x5623c649cd91]
STDERR: 6   0x5623c646ab72 /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xf5b72) [0x5623c646ab72]
STDERR: 7   0x5623c646ad89 /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xf5d89) [0x5623c646ad89]
STDERR: 8   0x5623c646adde /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xf5dde) [0x5623c646adde]
STDERR: 9   0x5623c646551e /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xf051e) [0x5623c646551e]
STDERR: 10  0x5623c64ca049 /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0x155049) [0x5623c64ca049]
STDERR: 11  0x7fb7f898d062 __libc_start_main
STDERR: 12  0x5623c645c5de /app/webkit/WebKitBuild/Debug/bin/WebKitTestRunner(+0xe75de) [0x5623c645c5de]
Comment 1 Carlos Alberto Lopez Perez 2021-03-30 16:30:35 PDT
Created attachment 424713 [details]
full crash log with threads
Comment 2 Jonathan Bedard 2021-03-30 17:03:47 PDT
Seems like the 0 and the content length are the most likely culprits.
Comment 3 Tim Horton 2021-03-30 18:10:51 PDT
Igalia folks, can you help diagnose this, since it doesn't seem to repro on the Apple ports?
Comment 4 Carlos Alberto Lopez Perez 2021-03-30 18:17:36 PDT
(In reply to Jonathan Bedard from comment #2)
> Seems like the 0 and the content length are the most likely culprits.

I tried this version of main-resource-redirect-blocked.py

$ cat LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked.py
#!/usr/bin/env python3

import sys

sys.stdout.write(
    'Location: resources/main-resource-redirect-blocked-target.html\r\n'
    'Status: 302\r\n'
    'Content-Length: 0\r\n'
    'Connection: close\r\n'
    'Content-Type: text/html\r\n\r\n'
)


Which gives this raw output

$ printf 'GET /contentextensions/main-resource-redirect-blocked.py HTTP/1.1\r\nHost: localhost\r\n\r\n' | nc localhost 8000
HTTP/1.1 302 Found
Date: Wed, 31 Mar 2021 01:07:18 GMT
Server: Apache/2.4.38 (Debian)
Connection: close
Location: resources/main-resource-redirect-blocked-target.html
Content-Length: 0
Content-Type: text/html


This way it doesn't print the 0 at the end and it exits immediately like the PHP version. Also the output it gives is almost the same than the previous PHP version. Major difference is that it replies with an HTTP/1.1 header instead of HTTP/1.0 (I couldn't find how to change the HTTP version from the python cgi script)


But is still crashing...

I also tried modifying the PHP version to use HTTP/1.1 and it is working with that one, so it is not directly related to that.


This is a bit weird.. :\
Comment 5 Carlos Alberto Lopez Perez 2021-03-30 19:07:03 PDT
Further debugging this I see that the request to the Apache server is never done in the case of main-resource-redirect-blocked.py. WTR crashes before doing the request.

However, If i rename main-resource-redirect-blocked.py to something else it works (I mean, the crash is gone)

And it seems the crash is triggered by the file LayoutTests/http/tests/contentextensions/main-resource-redirect-blocked.py.json ... If I delete this file then the test stops crashing.

Further debugging this I see WTR is trying to load this json file in the function TestController::configureContentExtensionForTest() 

From: https://trac.webkit.org/browser/webkit/trunk/Tools/WebKitTestRunner/TestController.cpp?rev=275046#L1427
1393	void TestController::configureContentExtensionForTest(const TestInvocation& test)
1394	{
[....]
1425	
1426	    WKPageSetUserContentExtensionsEnabled(mainWebView()->page(), true);
1427	    WKUserContentControllerAddUserContentFilter(userContentController(), context.filter.get());
1428	}

And it is crashing on the line 1427 because context.filter.get() is returning nullptr

This code was added in r241283
Comment 6 Carlos Alberto Lopez Perez 2021-03-30 20:34:22 PDT
Tests marked as crashing in r275263