Skip to content

Instantly share code, notes, and snippets.

@kkuehl
Last active August 18, 2024 12:30
Show Gist options
  • Save kkuehl/af5bbcd843a6239cee2c64b58be6def7 to your computer and use it in GitHub Desktop.
Save kkuehl/af5bbcd843a6239cee2c64b58be6def7 to your computer and use it in GitHub Desktop.
webkitgtk Asan Linux Compilation Instructions
wget --no-check-certificate http://nightly.webkit.org/files/WebKit-SVN-source.tar.bz2 -O WebKit-SVN-source.tar.bz2
tar jxvf WebKit-SVN-source.tar.bz2
cd webkit
echo Y | Tools/gtk/install-dependencies
Tools/Scripts/update-webkitgtk-libs
Apply the following patch:
--- Source/WebKit/PlatformGTK.cmake.orig 2017-09-26 13:04:14.571070291 -0700
+++ Source/WebKit/PlatformGTK.cmake 2017-09-26 13:04:31.871119018 -0700
@@ -1067,7 +1067,7 @@
install(TARGETS WebKitPluginProcess2 DESTINATION "${LIBEXEC_INSTALL_DIR}")
if (COMPILER_IS_GCC_OR_CLANG)
- WEBKIT_ADD_TARGET_CXX_FLAGS(WebKitPluginProcess2 -Wno-unused-parameter)
+ WEBKIT_ADD_TARGET_CXX_FLAGS(WebKitPluginProcess2 -Wno-unused-parameter -fsanitize=address -fno-omit-frame-pointer)
endif ()
endif () # ENABLE_PLUGIN_PROCESS_GTK2
@@ -1094,7 +1094,7 @@
target_link_libraries(webkit2gtkinjectedbundle WebKit)
if (COMPILER_IS_GCC_OR_CLANG)
- WEBKIT_ADD_TARGET_CXX_FLAGS(webkit2gtkinjectedbundle -Wno-unused-parameter)
+ WEBKIT_ADD_TARGET_CXX_FLAGS(webkit2gtkinjectedbundle -Wno-unused-parameter -fsanitize=address -fno-omit-frame-pointer)
endif ()
# Add ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} to LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
@@ -1125,7 +1125,8 @@
OUTPUT ${CMAKE_BINARY_DIR}/WebKit2-${WEBKITGTK_API_VERSION}.gir
DEPENDS WebKit
DEPENDS ${CMAKE_BINARY_DIR}/JavaScriptCore-${WEBKITGTK_API_VERSION}.gir
- COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=-Wno-deprecated-declarations LDFLAGS=
+ COMMAND CC=${CMAKE_C_COMPILER} CFLAGS="-Wno-deprecated-declarations -fsanitize=address"
+ LDFLAGS=-fsanitize=address
${LOADER_LIBRARY_PATH_VAR}="${INTROSPECTION_ADDITIONAL_LIBRARY_PATH}"
${INTROSPECTION_SCANNER}
--quiet
@@ -1169,7 +1170,7 @@
DEPENDS ${CMAKE_BINARY_DIR}/JavaScriptCore-${WEBKITGTK_API_VERSION}.gir
DEPENDS ${CMAKE_BINARY_DIR}/WebKit2-${WEBKITGTK_API_VERSION}.gir
COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=-Wno-deprecated-declarations
- LDFLAGS="${INTROSPECTION_ADDITIONAL_LDFLAGS}"
+ LDFLAGS=-fsanitize=address "${INTROSPECTION_ADDITIONAL_LDFLAGS}"
${LOADER_LIBRARY_PATH_VAR}="${INTROSPECTION_ADDITIONAL_LIBRARY_PATH}"
${INTROSPECTION_SCANNER}
--quiet
After the above patch has been applied:
Tools/Scripts/build-webkit --release --gtk --system-malloc --cmakeargs=-DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer -g -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
If I didn't add --private, I saw the following crash:
==30237==ERROR: AddressSanitizer: heap-use-after-free on address 0x611000002b60 at pc 0x7fea613b035e bp 0x7ffeca495c70 sp 0x7ffeca495c68
READ of size 1 at 0x611000002b60 thread T0
Tools/Scripts/run-minibrowser --gtk --private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment