1- diff -ruN webkitgtk-2.20.2-original/Source/WebCore/page/DOMWindow.cpp webkitgtk-2.20.2-patched/Source/WebCore/page/DOMWindow.cpp
2- --- webkitgtk-2.20.2-original/Source/WebCore/page/DOMWindow.cpp 2018-02-19 03:04:38.000000000 -0800
3- +++ webkitgtk-2.20.2-patched/Source/WebCore/page/DOMWindow.cpp 2018-06-07 08:48:13.506202000 -0700
1+ diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp
2+ index 546b4a4ddeeb..13852bcb263f 100644
3+ --- a/Source/WebCore/page/DOMWindow.cpp
4+ +++ b/Source/WebCore/page/DOMWindow.cpp
45@@ -27,6 +27,8 @@
56 #include "config.h"
67 #include "DOMWindow.h"
@@ -10,68 +11,45 @@ diff -ruN webkitgtk-2.20.2-original/Source/WebCore/page/DOMWindow.cpp webkitgtk-
1011 #include "BackForwardController.h"
1112 #include "BarProp.h"
1213 #include "CSSComputedStyleDeclaration.h"
13- @@ -1129 ,6 +1131 ,9 @@
14+ @@ -1122 ,6 +1124 ,9 @@ void DOMWindow::stop()
1415
1516 void DOMWindow::alert(const String& message)
1617 {
1718+ WebCore::GCController::singleton().garbageCollectNow();
1819+ return;
1920+
20- if (!m_frame)
21+ RefPtr frame = this->frame();
22+ if (!frame)
2123 return;
22-
23- diff -ruN webkitgtk-2.20.2-original/Source/WebKit/PlatformGTK.cmake webkitgtk-2.20.2-patched/Source/WebKit/PlatformGTK.cmake
24- --- webkitgtk-2.20.2-original/Source/WebKit/PlatformGTK.cmake 2018-04-10 00:33:13.000000000 -0700
25- +++ webkitgtk-2.20.2-patched/Source/WebKit/PlatformGTK.cmake 2018-08-30 04:41:59.686417149 -0700
26- @@ -732,7 +732,7 @@
27- OUTPUT ${CMAKE_BINARY_DIR}/WebKit2-${WEBKITGTK_API_VERSION}.gir
28- DEPENDS WebKit
29- DEPENDS ${CMAKE_BINARY_DIR}/JavaScriptCore-${WEBKITGTK_API_VERSION}.gir
30- - COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=-Wno-deprecated-declarations LDFLAGS=
31- + COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=\"-Wno-deprecated-declarations -fsanitize=address\" LDFLAGS=\"-fsanitize=address\"
32- ${LOADER_LIBRARY_PATH_VAR}="${INTROSPECTION_ADDITIONAL_LIBRARY_PATH}"
33- ${INTROSPECTION_SCANNER}
34- --quiet
35- @@ -774,8 +774,8 @@
36- OUTPUT ${CMAKE_BINARY_DIR}/WebKit2WebExtension-${WEBKITGTK_API_VERSION}.gir
37- DEPENDS ${CMAKE_BINARY_DIR}/JavaScriptCore-${WEBKITGTK_API_VERSION}.gir
38- DEPENDS ${CMAKE_BINARY_DIR}/WebKit2-${WEBKITGTK_API_VERSION}.gir
39- - COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=-Wno-deprecated-declarations
40- - LDFLAGS="${INTROSPECTION_ADDITIONAL_LDFLAGS}"
41- + COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=\"-Wno-deprecated-declarations -fsanitize=address\"
42- + LDFLAGS=\"${INTROSPECTION_ADDITIONAL_LDFLAGS} -fsanitize=address\"
43- ${LOADER_LIBRARY_PATH_VAR}="${INTROSPECTION_ADDITIONAL_LIBRARY_PATH}"
44- ${INTROSPECTION_SCANNER}
45- --quiet
46- diff -ruN webkitgtk-2.20.2-original/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp webkitgtk-2.20.2-patched/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp
47- --- webkitgtk-2.20.2-original/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp 2018-02-19 22:53:53.000000000 -0800
48- +++ webkitgtk-2.20.2-patched/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp 2018-06-07 08:56:57.436930000 -0700
49- @@ -40,6 +40,9 @@
24+ diff --git a/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp b/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp
25+ index 124bfc3f16e8..137ae153100c 100644
26+ --- a/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp
27+ +++ b/Source/WebKit/UIProcess/Launcher/glib/ProcessLauncherGLib.cpp
28+ @@ -41,6 +41,8 @@
29+ #include <wtf/glib/Sandbox.h>
5030 #include <wtf/text/CString.h>
5131 #include <wtf/text/WTFString.h>
52-
5332+ #include <sys/types.h>
5433+ #include <sys/wait.h>
55- +
56- #if PLATFORM(WPE)
57- #include <wpe/renderer-host.h>
34+
35+ #if !USE(SYSTEM_MALLOC) && OS(LINUX)
36+ #include <bmalloc/valgrind.h>
37+ @@ -68,6 +70,151 @@ static bool isFlatpakSpawnUsable()
38+ }
5839 #endif
59- @@ -47,6 +50,149 @@
60- namespace WebKit {
61- using namespace WebCore;
6240
6341+ void HandleAsanReport(pid_t pid) {
6442+ // 1. Get the "log_path" from ASAN_OPTIONS.
6543+ // 2. Copy the log_path.[pid] to log_path.[mypid].
6644+ char *options = getenv("ASAN_OPTIONS");
6745+ if (options == NULL) {
68- + fprintf(stdout, "error: no ASAN_OPTIONS\n");
46+ + fprintf(stdout, "[webkitfuzz]: error: no ASAN_OPTIONS\n");
6947+ return;
7048+ }
7149+
7250+ char *log_path = strstr(options, "log_path=");
7351+ if (log_path == NULL) {
74- + fprintf(stdout, "error: no log_path=\n");
52+ + fprintf(stdout, "[webkitfuzz]: error: no ASAN log_path=\n");
7553+ return;
7654+ }
7755+
@@ -102,7 +80,7 @@ diff -ruN webkitgtk-2.20.2-original/Source/WebKit/UIProcess/Launcher/glib/Proces
10280+
10381+ free(log_path);
10482+
105- + FILE *f_src = fopen(src_path, "rb");
83+ + FILE *f_src = fopen(src_path, "rb");
10684+ if (f_src == NULL) {
10785+ fprintf(stdout, "error: %s not found\n", src_path);
10886+ return;
@@ -128,31 +106,31 @@ diff -ruN webkitgtk-2.20.2-original/Source/WebKit/UIProcess/Launcher/glib/Proces
128106+
129107+ fclose(f_dst);
130108+ fclose(f_src);
131- + fprintf(stdout, "note: ASAN logs copied from %s to %s\n",
109+ + fprintf(stdout, "[webkitfuzz]: note: ASAN logs copied from %s to %s\n",
132110+ src_path, dst_path);
133111+ free(src_path);
134112+ free(dst_path);
135113+ }
136114+
137115+ void *wait_thread(void *arg) {
138- + fprintf(stdout, "Started WebProcess, starting monitoring thread.\n");
116+ + fprintf(stdout, "[webkitfuzz]: Started WebProcess, starting monitoring thread.\n");
139117+
140118+ pid_t pid = (pid_t)(size_t)arg;
141119+
142- + fprintf(stdout, "pid: %i\n", pid);
120+ + fprintf(stdout, "[webkitfuzz]: pid: %i\n", pid);
143121+
144122+ for (;;) {
145123+ int status = 0;
146124+ pid_t ev_pid = waitpid(pid, &status, __WALL);
147125+
148- + fprintf(stdout, "ev_pid: %i, status: %.8x\n", ev_pid, status);
126+ + fprintf(stdout, "[webkitfuzz]: ev_pid: %i, status: %.8x\n", ev_pid, status);
149127+
150128+ if (ev_pid == -1) {
151129+ if (errno == ECHILD) {
152- + fprintf(stdout, "all children exited\n");
130+ + fprintf(stdout, "[webkitfuzz]: all children exited\n");
153131+ return NULL;
154132+ }
155- + fprintf(stdout, "errno: %i\n", errno);
133+ + fprintf(stdout, "[webkitfuzz]: errno: %i\n", errno);
156134+ perror("error");
157135+ return NULL;
158136+ }
@@ -203,48 +181,39 @@ diff -ruN webkitgtk-2.20.2-original/Source/WebKit/UIProcess/Launcher/glib/Proces
203181+ return NULL;
204182+ }
205183+
206- static void childSetupFunction(gpointer userData)
184+ +
185+ +
186+ void ProcessLauncher::launchProcess()
207187 {
208- int socket = GPOINTER_TO_INT(userData);
209- @@ -138,8 +284,20 @@
210- argv[i++] = nullptr;
188+ IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection(IPC::Connection::ConnectionOptions::SetCloexecOnServer);
189+ @@ -170,6 +317,12 @@ void ProcessLauncher::launchProcess()
190+ m_processIdentifier = g_ascii_strtoll(processIdStr, nullptr, 0);
191+ RELEASE_ASSERT(m_processIdentifier);
211192
212- GUniqueOutPtr<GError> error;
213- - if (!g_spawn_async(nullptr, argv, nullptr, G_SPAWN_LEAVE_DESCRIPTORS_OPEN, childSetupFunction, GINT_TO_POINTER(socketPair.server), &pid, &error.outPtr()))
214- - g_error("Unable to fork a new child process: %s", error->message);
215- +
216- + if(m_launchOptions.processType == ProcessLauncher::ProcessType::Web) {
217- + if (!g_spawn_async(nullptr, argv, nullptr, GSpawnFlags(G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_DO_NOT_REAP_CHILD), childSetupFunction, GINT_TO_POINTER(socketPair.server), &pid, &error.outPtr())) {
218- + g_printerr("Unable to fork a new WebProcess: %s.\n", error->message);
219- + ASSERT_NOT_REACHED();
220- + }
221- + pthread_t thread_id;
222- + pthread_create(&thread_id, NULL, wait_thread, (void *)pid);
223- + } else {
224- + if (!g_spawn_async(nullptr, argv, nullptr, G_SPAWN_LEAVE_DESCRIPTORS_OPEN, childSetupFunction, GINT_TO_POINTER(socketPair.server), &pid, &error.outPtr())) {
225- + g_printerr("Unable to fork a new WebProcess: %s.\n", error->message);
226- + ASSERT_NOT_REACHED();
227- + }
193+ + pthread_t thread_id;
194+ + int retval = pthread_create(&thread_id, NULL, wait_thread, (void *)m_processIdentifier);
195+ + if (retval != 0) {
196+ + g_error("[webkitfuzz]: pthread_create failed\n");
228197+ }
229-
198+ +
230199 // Don't expose the parent socket to potential future children.
231200 if (!setCloseOnExec(socketPair.client))
232- diff -ruN webkitgtk-2.20.2-original/Tools/CMakeLists.txt webkitgtk-2.20.2-patched/Tools/CMakeLists.txt
233- --- webkitgtk-2.20.2-original /Tools/CMakeLists.txt 2018-02-18 23:45:33.000000000 -0800
234- +++ webkitgtk-2.20.2-patched/Tools/CMakeLists.txt 2018-06-07 08:57:57.872532000 -0700
235- @@ -15,6 +15,9 @@
236- if (ENABLE_MINIBROWSER)
237- add_subdirectory(MiniBrowser/gtk )
238- endif ( )
239- +
240- + add_subdirectory(webkitfuzz )
241- +
242- elseif ("${PORT}" STREQUAL "Mac" )
243- add_subdirectory(DumpRenderTree)
244- add_subdirectory(WebKitTestRunner)
245- diff -ruN webkitgtk-2.20.2-original/Tools/webkitfuzz/CMakeLists.txt webkitgtk-2.20.2-patched/Tools/webkitfuzz/CMakeLists.txt
246- --- webkitgtk-2.20.2-original/Tools/webkitfuzz/CMakeLists.txt 1969-12-31 16:00:00.000000000 -0800
247- +++ webkitgtk-2.20.2-patched /Tools/webkitfuzz/CMakeLists.txt 2017-12-13 06:42:56.968691000 -0800
201+ RELEASE_ASSERT_NOT_REACHED();
202+ diff --git a /Tools/PlatformGTK.cmake b/Tools/PlatformGTK.cmake
203+ index 37e1b0b7138d..5b9579597912 100644
204+ --- a/Tools/PlatformGTK.cmake
205+ +++ b/Tools/PlatformGTK.cmake
206+ @@ -12,3 +12,5 @@ endif ( )
207+ if (ENABLE_MINIBROWSER )
208+ add_subdirectory(MiniBrowser/gtk)
209+ endif ( )
210+ +
211+ + add_subdirectory(webkitfuzz )
212+ diff --git a/Tools/webkitfuzz/CMakeLists.txt b/Tools/webkitfuzz/CMakeLists.txt
213+ new file mode 100644
214+ index 000000000000..d71e14610257
215+ --- /dev/null
216+ +++ b /Tools/webkitfuzz/CMakeLists.txt
248217@@ -0,0 +1,40 @@
249218+ set(WEBKITFUZZ_DIR "${TOOLS_DIR}/webkitfuzz")
250219+
@@ -286,10 +255,12 @@ diff -ruN webkitgtk-2.20.2-original/Tools/webkitfuzz/CMakeLists.txt webkitgtk-2.
286255+ target_link_libraries(webkitfuzz ${webkitfuzz_LIBRARIES})
287256+
288257+ install(TARGETS webkitfuzz DESTINATION "${LIBEXEC_INSTALL_DIR}")
289- diff -ruN webkitgtk-2.20.2-original/Tools/webkitfuzz/main.c webkitgtk-2.20.2-patched/Tools/webkitfuzz/main.c
290- --- webkitgtk-2.20.2-original/Tools/webkitfuzz/main.c 1969-12-31 16:00:00.000000000 -0800
291- +++ webkitgtk-2.20.2-patched/Tools/webkitfuzz/main.c 2018-08-30 04:48:22.833020025 -0700
292- @@ -0,0 +1,122 @@
258+ diff --git a/Tools/webkitfuzz/main.c b/Tools/webkitfuzz/main.c
259+ new file mode 100644
260+ index 000000000000..a02da70dd451
261+ --- /dev/null
262+ +++ b/Tools/webkitfuzz/main.c
263+ @@ -0,0 +1,125 @@
293264+ #include <gtk/gtk.h>
294265+ #include <webkit2/webkit2.h>
295266+
@@ -318,7 +289,7 @@ diff -ruN webkitgtk-2.20.2-original/Tools/webkitfuzz/main.c webkitgtk-2.20.2-pat
318289+ int main(int argc, char* argv[])
319290+ {
320291+ int inputtype = TYPE_FILE;
321- + char *databuf;
292+ + char *databuf;
322293+
323294+ if(argc < 2) {
324295+ printf("Usage: %s <url|file> [timeout]\n", argv[0]);
@@ -332,10 +303,7 @@ diff -ruN webkitgtk-2.20.2-original/Tools/webkitfuzz/main.c webkitgtk-2.20.2-pat
332303+ timeout = TIMEOUT;
333304+ }
334305+
335- + //pthread_t thread_id;
336- + //pthread_create(&thread_id, NULL, wait_thread, NULL);
337- +
338- + printf("webkitfuzz started\n");
306+ + printf("webkitfuzz started: %s\n",argv[1]);
339307+
340308+ if((strncmp(argv[1],"http://", 7) == 0) || (strncmp(argv[1],"https://", 8) == 0)) {
341309+ inputtype = TYPE_URL;
@@ -358,7 +326,6 @@ diff -ruN webkitgtk-2.20.2-original/Tools/webkitfuzz/main.c webkitgtk-2.20.2-pat
358326+ // Initialize GTK+
359327+ gtk_init(&argc, &argv);
360328+
361- + webkit_web_context_set_process_model(webkit_web_context_get_default(), WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
362329+
363330+ // Create an 800x600 window that will contain the browser instance
364331+ GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -368,6 +335,13 @@ diff -ruN webkitgtk-2.20.2-original/Tools/webkitfuzz/main.c webkitgtk-2.20.2-pat
368335+ // Create a browser instance
369336+ WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
370337+
338+ + // Set settings for console messages to be written to stdout
339+ + WebKitSettings *settings = webkit_web_view_get_settings(webView);
340+ + webkit_settings_set_enable_write_console_messages_to_stdout(settings, TRUE);
341+ +
342+ + // Enable or disable WebGL
343+ + //webkit_settings_set_enable_webgl(settings, FALSE);
344+ +
371345+ // Put the browser area into the main window
372346+ gtk_container_add(GTK_CONTAINER(main_window), GTK_WIDGET(webView));
373347+
0 commit comments