diff options
author | Rasmus <oss@cogitri.dev> | 2021-04-28 17:21:16 +0200 |
---|---|---|
committer | Rasmus Thomsen <oss@cogitri.dev> | 2021-04-30 12:52:41 +0200 |
commit | c447093ce07920819e97895f7173179f430cead3 (patch) | |
tree | 0569d121ad95933fd8997a07efcb8e6a5b4488b0 | |
parent | b99d25f04b00ed7048a4dbdd7a3fea546e66b4b4 (diff) |
community/webkit2gtk: apply upstream patches for fixing stacksize problems
With these patches applied, webkit2gtk shouldn't crash anymore on JS heavy
websites. Thanks for working on them, @q66!
-rw-r--r-- | community/webkit2gtk/APKBUILD | 14 | ||||
-rw-r--r-- | community/webkit2gtk/fix-fast-memory-disabled.patch | 14 | ||||
-rw-r--r-- | community/webkit2gtk/fix-openjpeg.patch | 11 | ||||
-rw-r--r-- | community/webkit2gtk/lower-stack-usage.patch | 17 | ||||
-rw-r--r-- | community/webkit2gtk/musl-fixes.patch | 34 | ||||
-rw-r--r-- | community/webkit2gtk/musl-stack-fix.patch | 74 | ||||
-rw-r--r-- | community/webkit2gtk/musl-wordsize.patch | 59 |
7 files changed, 162 insertions, 61 deletions
diff --git a/community/webkit2gtk/APKBUILD b/community/webkit2gtk/APKBUILD index e1f52be056d..9718d04a667 100644 --- a/community/webkit2gtk/APKBUILD +++ b/community/webkit2gtk/APKBUILD @@ -4,7 +4,7 @@ # Maintainer: Rasmus Thomsen <oss@cogitri.dev> pkgname=webkit2gtk pkgver=2.32.0 -pkgrel=0 +pkgrel=1 pkgdesc="Portable web rendering engine WebKit for GTK+" url="https://webkitgtk.org/" arch="all !mips !mips64" @@ -55,10 +55,9 @@ replaces="webkit" options="!check" # upstream doesn't package them in release tarballs: Tools/Scripts/run-gtk-tests: Command not found subpackages="$pkgname-dev $pkgname-lang $pkgname-dbg" source="https://webkitgtk.org/releases/webkitgtk-$pkgver.tar.xz - fix-fast-memory-disabled.patch musl-fixes.patch - fix-openjpeg.patch - lower-stack-usage.patch + musl-stack-fix.patch + musl-wordsize.patch " builddir="$srcdir/webkitgtk-$pkgver" @@ -256,7 +255,6 @@ package() { } sha512sums="4832a4614be24481028ca8a6480a8e6cfacd8e22f5ba9f936703c09944550056f06f75ccf8fffa7dee3f5a1d11ab1870841407745be2e61ebad6557a0934db15 webkitgtk-2.32.0.tar.xz -a542a874a20d9063dcbc6a2d6d3827bd4dbc090dbc2e0d31471b7ad67590cf33e88dc4796a768691fdcd3214a99e64c4d1010a1852239352aec107c0b8d38fe7 fix-fast-memory-disabled.patch -4c0093e4a38c8ceb3ac92b94539ec1417241814a84abd157442f53f710ecbaf9c2345e258b8ad86d5e0908cacbfca6cad28dedd11c127756b65428f359ba9fcc musl-fixes.patch -d86fbc3ffb4f5d5a61d3bd7098c9d4fef53c55be21a48f54cdb28098041e3be2f641a4628ca20fa6b5b5e29ad5bd94dac00a362c4bfc011c2e9118a6661d5ad0 fix-openjpeg.patch -14b3f8e93fe2afbc09660216c396483c572364f68851355c4125fd4f220cc2710c27321b2d8b3c35903b446acb086eb3f7666a3b59941584e7bde2654d16c036 lower-stack-usage.patch" +49512e1b7cdd101971795437d04448e59a0c532955c271694675d53bc80a32a8f4166e46942ed148185ac0ac6be07acae8083605f8fed7b1bb4b224afb089b5d musl-fixes.patch +b80bcf92618992350e225cd635b503f963a299c2a1f80f17c3b6dd232ac300c8e2dd96aecfdf0a4d7f3e1bd7ed38247460a3b6f9e5871add119301cbca65d596 musl-stack-fix.patch +787ec4a7f8f005808e8fb8dc65cfcf676a5afbc8b9fbc40e203a155ed8da9b7d5cf7d559637e1d2738d5ff3af6764e8cd1af186f8bd946444f344a8be5ab5ad0 musl-wordsize.patch" diff --git a/community/webkit2gtk/fix-fast-memory-disabled.patch b/community/webkit2gtk/fix-fast-memory-disabled.patch deleted file mode 100644 index cd4f812f1f4..00000000000 --- a/community/webkit2gtk/fix-fast-memory-disabled.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp -+++ b/Source/JavaScriptCore/wasm/WasmFaultSignalHandler.cpp -@@ -99,7 +99,11 @@ void unregisterCode(void* start, void* e - - bool fastMemoryEnabled() - { -+#if ENABLE(WEBASSEMBLY_FAST_MEMORY) - return fastHandlerInstalled; -+#else -+ return false; -+#endif // ENABLE(WEBASSEMBLY_FAST_MEMORY) - } - - void enableFastMemory() diff --git a/community/webkit2gtk/fix-openjpeg.patch b/community/webkit2gtk/fix-openjpeg.patch deleted file mode 100644 index b884fa36b30..00000000000 --- a/community/webkit2gtk/fix-openjpeg.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp -+++ b/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp -@@ -28,7 +28,7 @@ - - #if USE(OPENJPEG) - --#include <openjpeg.h> -+#include <openjpeg-2.4/openjpeg.h> - - namespace WebCore { - diff --git a/community/webkit2gtk/lower-stack-usage.patch b/community/webkit2gtk/lower-stack-usage.patch deleted file mode 100644 index 27fd216fce0..00000000000 --- a/community/webkit2gtk/lower-stack-usage.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/Source/JavaScriptCore/runtime/OptionsList.h b/Source/JavaScriptCore/runtime/OptionsList.h -index 41cab118..2ac66c7a 100644 ---- a/Source/JavaScriptCore/runtime/OptionsList.h -+++ b/Source/JavaScriptCore/runtime/OptionsList.h -@@ -90,9 +90,9 @@ constexpr bool enableWebAssemblyStreamingApi = false; - \ - v(Bool, reportMustSucceedExecutableAllocations, false, Normal, nullptr) \ - \ -- v(Unsigned, maxPerThreadStackUsage, 5 * MB, Normal, "Max allowed stack usage by the VM") \ -- v(Unsigned, softReservedZoneSize, 128 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \ -- v(Unsigned, reservedZoneSize, 64 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \ -+ v(Unsigned, maxPerThreadStackUsage, 80 * KB , Normal, "Max allowed stack usage by the VM") \ -+ v(Unsigned, softReservedZoneSize, 32 * KB, Normal, "A buffer greater than reservedZoneSize that reserves space for stringifying exceptions.") \ -+ v(Unsigned, reservedZoneSize, 16 * KB, Normal, "The amount of stack space we guarantee to our clients (and to interal VM code that does not call out to clients).") \ - \ - v(Bool, crashOnDisallowedVMEntry, ASSERT_ENABLED, Normal, "Forces a crash if we attempt to enter the VM when disallowed") \ - v(Bool, crashIfCantAllocateJITMemory, false, Normal, nullptr) \ diff --git a/community/webkit2gtk/musl-fixes.patch b/community/webkit2gtk/musl-fixes.patch index e28d9a5a22b..0bcb1336598 100644 --- a/community/webkit2gtk/musl-fixes.patch +++ b/community/webkit2gtk/musl-fixes.patch @@ -1,51 +1,52 @@ +Upstream: yes + --- a/Source/JavaScriptCore/runtime/MachineContext.h +++ b/Source/JavaScriptCore/runtime/MachineContext.h -@@ -188,7 +188,7 @@ static inline void*& stackPointerImpl(mcontext_t& machineContext) +@@ -196,7 +196,7 @@ static inline void*& stackPointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) -+#elif OS(FUCHSIA) || defined(__linux__) ++#elif OS(FUCHSIA) || OS(LINUX) #if CPU(X86) return reinterpret_cast<void*&>((uintptr_t&) machineContext.gregs[REG_ESP]); -@@ -335,7 +335,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext) +@@ -347,7 +347,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) -+#elif OS(FUCHSIA) || defined(__linux__) ++#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) -@@ -482,7 +482,7 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext) +@@ -498,7 +498,7 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) -+#elif OS(FUCHSIA) || defined(__linux__) ++#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) -@@ -639,7 +639,7 @@ inline void*& argumentPointer<1>(mcontext_t& machineContext) +@@ -656,7 +656,7 @@ inline void*& argumentPointer<1>(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) -+#elif OS(FUCHSIA) || defined(__linux__) ++#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) -@@ -756,7 +756,7 @@ inline void*& llintInstructionPointer(mcontext_t& machineContext) +@@ -773,7 +773,7 @@ inline void*& llintInstructionPointer(mcontext_t& machineContext) #error Unknown Architecture #endif -#elif OS(FUCHSIA) || defined(__GLIBC__) || defined(__BIONIC__) -+#elif OS(FUCHSIA) || defined(__linux__) ++#elif OS(FUCHSIA) || OS(LINUX) // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) - --- a/Source/WebCore/xml/XPathGrammar.cpp +++ b/Source/WebCore/xml/XPathGrammar.cpp @@ -966,7 +966,7 @@ int yydebug; @@ -66,3 +67,14 @@ # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in +--- a/Source/WTF/wtf/PlatformHave.h ++++ b/Source/WTF/wtf/PlatformHave.h +@@ -206,7 +206,7 @@ + #define HAVE_HOSTED_CORE_ANIMATION 1 + #endif + +-#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || defined(__GLIBC__) || defined(__BIONIC__)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))) ++#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))) + #define HAVE_MACHINE_CONTEXT 1 + #endif + diff --git a/community/webkit2gtk/musl-stack-fix.patch b/community/webkit2gtk/musl-stack-fix.patch new file mode 100644 index 00000000000..8f4e19a497d --- /dev/null +++ b/community/webkit2gtk/musl-stack-fix.patch @@ -0,0 +1,74 @@ +https://bugs.webkit.org/show_bug.cgi?id=225099 + +From ab7e2bfae280b151ac173d6fc9d8eaa3da2e92a8 Mon Sep 17 00:00:00 2001 +From: q66 <daniel@octaforge.org> +Date: Tue, 27 Apr 2021 22:51:22 +0200 +Subject: [PATCH] fix stack size issues on musl + +--- + Source/WTF/wtf/StackBounds.cpp | 26 +++++++++++++++++++++++++- + Source/WTF/wtf/Threading.cpp | 4 ++++ + 2 files changed, 29 insertions(+), 1 deletion(-) + +diff --git Source/WTF/wtf/StackBounds.cpp Source/WTF/wtf/StackBounds.cpp +index e6f7095..58bdb18 100644 +--- a/Source/WTF/wtf/StackBounds.cpp ++++ b/Source/WTF/wtf/StackBounds.cpp +@@ -36,6 +36,12 @@ + #include <pthread_np.h> + #endif + ++#if OS(LINUX) ++#include <sys/resource.h> ++#include <sys/syscall.h> ++#include <unistd.h> ++#endif ++ + #endif + + namespace WTF { +@@ -107,7 +113,25 @@ StackBounds StackBounds::newThreadStackBounds(PlatformThreadHandle thread) + + StackBounds StackBounds::currentThreadStackBoundsInternal() + { +- return newThreadStackBounds(pthread_self()); ++ auto ret = newThreadStackBounds(pthread_self()); ++#if OS(LINUX) ++ // on glibc, pthread_attr_getstack will generally return the limit size (minus a guard page) ++ // for the main thread; this is however not necessarily always true on every libc - for example ++ // on musl, it will return the currently reserved size - since the stack bounds are expected to ++ // be constant (and they are for every thread except main, which is allowed to grow), check ++ // resource limits and use that as the boundary instead (and prevent stack overflows in JSC) ++ if (getpid() == static_cast<pid_t>(syscall(SYS_gettid))) { ++ void* origin = ret.origin(); ++ rlimit limit; ++ getrlimit(RLIMIT_STACK, &limit); ++ rlim_t size = limit.rlim_cur; ++ // account for a guard page ++ size -= static_cast<rlim_t>(sysconf(_SC_PAGESIZE)); ++ void* bound = static_cast<char*>(origin) - size; ++ return StackBounds { origin, bound }; ++ } ++#endif ++ return ret; + } + + #elif OS(WINDOWS) +diff --git Source/WTF/wtf/Threading.cpp Source/WTF/wtf/Threading.cpp +index 99d09c0..362bf35 100644 +--- a/Source/WTF/wtf/Threading.cpp ++++ b/Source/WTF/wtf/Threading.cpp +@@ -58,6 +58,10 @@ static Optional<size_t> stackSize(ThreadType threadType) + + #if defined(DEFAULT_THREAD_STACK_SIZE_IN_KB) && DEFAULT_THREAD_STACK_SIZE_IN_KB > 0 + return DEFAULT_THREAD_STACK_SIZE_IN_KB * 1024; ++#elif OS(LINUX) && !defined(__BIONIC__) && !defined(__GLIBC__) ++ // on libc's other than glibc and bionic (e.g. musl) we are either unsure how big ++ // the default thread stack is, or we know it's too small - pick a robust default ++ return 1 * MB; + #else + // Use the platform's default stack size + return WTF::nullopt; +-- +2.30.1 + diff --git a/community/webkit2gtk/musl-wordsize.patch b/community/webkit2gtk/musl-wordsize.patch new file mode 100644 index 00000000000..d83e70bdf07 --- /dev/null +++ b/community/webkit2gtk/musl-wordsize.patch @@ -0,0 +1,59 @@ +Upstream: yes + +From 1b7144916774dbb4cc4705ba9a4377844e35f47d Mon Sep 17 00:00:00 2001 +From: q66 <daniel@octaforge.org> +Date: Tue, 27 Apr 2021 22:56:33 +0200 +Subject: [PATCH] remove __WORDSIZE usage + +--- + Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp | 6 +++--- + Source/WebCore/rendering/RenderLayerBacking.h | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp +index cfe3698..e5bc870 100644 +--- a/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp ++++ b/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp +@@ -39,7 +39,7 @@ namespace CryptoAlgorithmAES_GCMInternal { + static const char* const ALG128 = "A128GCM"; + static const char* const ALG192 = "A192GCM"; + static const char* const ALG256 = "A256GCM"; +-#if __WORDSIZE >= 64 ++#if CPU(ADDRESS64) + static const uint64_t PlainTextMaxLength = 549755813632ULL; // 2^39 - 256 + #endif + static const uint8_t DefaultTagLength = 128; +@@ -77,7 +77,7 @@ void CryptoAlgorithmAES_GCM::encrypt(const CryptoAlgorithmParameters& parameters + + auto& aesParameters = downcast<CryptoAlgorithmAesGcmParams>(parameters); + +-#if __WORDSIZE >= 64 ++#if CPU(ADDRESS64) + if (plainText.size() > PlainTextMaxLength) { + exceptionCallback(OperationError); + return; +@@ -120,7 +120,7 @@ void CryptoAlgorithmAES_GCM::decrypt(const CryptoAlgorithmParameters& parameters + return; + } + +-#if __WORDSIZE >= 64 ++#if CPU(ADDRESS64) + if (aesParameters.ivVector().size() > UINT64_MAX) { + exceptionCallback(OperationError); + return; +diff --git Source/WebCore/rendering/RenderLayerBacking.h Source/WebCore/rendering/RenderLayerBacking.h +index 9960724..193c5d1 100644 +--- a/Source/WebCore/rendering/RenderLayerBacking.h ++++ b/Source/WebCore/rendering/RenderLayerBacking.h +@@ -43,7 +43,7 @@ class TiledBacking; + class TransformationMatrix; + + +-#if __WORDSIZE == 64 && PLATFORM(COCOA) ++#if CPU(ADDRESS64) && PLATFORM(COCOA) + #define USE_OWNING_LAYER_BEAR_TRAP 1 + #define BEAR_TRAP_VALUE 0xEEEEEEEEEEEEEEEE + #else +-- +2.30.1 + |