Re: [voidlinux/void-packages] JavaScript seems to not work in WebKit-GTK+ web browsers on musl x86 (#5360)

mmmmarascio at Thu, 15 Dec 2016 09:15:46 -0800
yes @Duncaen
mmmmarascio at Sat, 17 Dec 2016 19:53:09 -0800
@Duncaen: Interesting. I created a patch from that Openwall discussion[*] ``` --- Source/JavaScriptCore/runtime/VMEntryScope.cpp.orig 2016-04-09 23:48:36.000000000 -0700 +++ Source/JavaScriptCore/runtime/VMEntryScope.cpp 2016-12-17 08:52:06.336000000 -0700 @@ -84,8 +84,8 @@ // // These sizes were derived from the stack usage of a number of sites when // layout occurs when we've already consumed most of the C stack. - const size_t requiredStack = 128 * KB; - const size_t errorModeRequiredStack = 64 * KB; + const size_t requiredStack = 32 * KB; + const size_t errorModeRequiredStack = 16 * KB; size_t requiredCapacity = interpreter->isInErrorHandlingMode() ? errorModeRequiredStack : requiredStack; RELEASE_ASSERT(m_stack.size() >= requiredCapacity); ``` then patched and built webkit with xbps-src. The result is that JavaScript appears to work in surf and that xombrero segfaults on startup. [*]: <http://www.openwall.com/lists/musl/2014/11/04/1>
svenper at Tue, 21 Feb 2017 11:25:46 -0800
I think I'm having a similar issue on x64. Any idea what the appropriate change would be in the [webkit2 source](https://webkitgtk.org/releases/webkitgtk-2.14.4.tar.xz)? I am trying to get it working with the [surf-webkit2 branch](http://git.suckless.org/surf/tree/?h=surf-webkit2) (xbps-src [template](https://gist.githubusercontent.com/svenper/abb0438f77319bea4d33d9ce8456f26e/raw/34e278670f2ae30e82e5b5062eb04b97ab708550)) and currently everything seems to be working except JavaScript.
Pavel Kiselev at Fri, 19 May 2017 10:33:50 -0700
I tried bumping `musl`'s stack size from the default all the way up to `glibc`'s 8MB, as per https://github.com/voidlinux/void-packages/issues/4147. It fixed _some_ JavaScript, but, sadly, not all of it. Some sites that are okay on `glibc` still don't function properly on `musl` (tested on surf and Midori).
Pavel Kiselev at Fri, 19 May 2017 13:20:49 -0700
@Duncaen no, rebuild did nothing at all. I find that in most cases apps that are affected by stack problem are usually fixed without need for rebuilding them (e.g. file managers crashing when thumbnailing certain files stops immidiately after reinstalling `musl`). P.S. (offtop) oh my god this thing build for 3 goddamn hours! And I wondered what Suckless people meant by "replacing WebKit with something sensible".
svenper at Sat, 20 May 2017 12:58:09 -0700
@E100Beta rebuilding `musl` with a larger stack size has no effect for me, even after rebooting. Did you do anything else? ``` $ ps xc | grep -e surf -e WebKit 5999 ? Ssl 0:07 surf 6016 ? Sl 0:10 WebKitNetworkPr 6019 ? Sl 0:59 WebKitWebProces $ cat /proc/{5999,6016,6019}/limits | grep stack Max stack size 8388608 unlimited bytes Max stack size 8388608 unlimited bytes Max stack size 8388608 unlimited bytes ```
Pavel Kiselev at Sat, 20 May 2017 13:10:43 -0700
@svenper Only _some_ javascript starts working after rebuilding `musl`. **A lot** of it is still non-functional, sadly (like, I now can actually log into vk.com (which is the most complex sites in terms of javascript I frequently visit, so I test on it first of all), but some buttons that trigger background content loading or displaying some previously hidden parts of the page are still not working). I can't tell exactly what functionality is fixed by it exactly, I'm not too experienced in js :(
bitshark at Fri, 23 Feb 2018 21:01:51 +0000 (UTC)
I'm having the same problem with x86_64 musl libc , using typecatcher (a python GTK based client for downloading Google fonts). It works fine within an lxc container with the same kernel on Ubuntu 16, but with Void Linux musl x86_64 I'm getting the following error: "Message: console message: undefined @0: RangeError: Maximum call stack size exceeded." I'll try rebuilding musl with the larger stack size and see if that has any effect.
bitshark at Fri, 23 Feb 2018 21:21:23 +0000 (UTC)
Update: I tried the LD_PRELOAD trick with no effect. (compiled file found here https://gist.githubusercontent.com/davidwindell/13a09511117fdd1523b9f31c0bb23dd5/raw/560df4b8ad682d6494dfb85cee2df7b42f63cde2/stack-fix.c ) into a shared object with gcc -shared -fPIC /lib/stack-fix.c -o /lib/stack-fix.so. LD_PRELOAD=/lib/stack-fix.so python3 import typecatcher typecatcher.main() ``` (typecatcher3) [user@dolphin ~]$ LD_PRELOAD=/home/user/stack-fix.so python3 Python 3.6.4 (default, Dec 19 2017, 18:03:06) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import typecatcher /tank/home/user/venv/typecatcher3/lib/python3.6/site-packages/typecatcher_lib/helpers.py:23: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded. from gi.repository import Gtk, Gio /tank/home/user/venv/typecatcher3/lib/python3.6/site-packages/typecatcher/TypeCatcherWindow.py:20: PyGIWarning: WebKit was imported without specifying a version first. Use gi.require_version('WebKit', '3.0') before import to ensure that the right version gets loaded. from gi.repository import WebKit t>>> typecatcher.main() ** Message: console message: undefined @0: RangeError: Maximum call stack size exceeded. ** Message: console message: undefined @0: RangeError: Maximum call stack size exceeded. ```
bitshark at Wed, 28 Feb 2018 04:28:15 +0000 (UTC)
Still working this issue: - recompiled musl with the bigstack option (no effect) - recompiled musl with the debug symbols so i could see where TypeCatcher was segfaulting... - looks like the segfault is in /usr/lib/libjavascriptcoregtk-3.0.so.0.16.19 somewhere (which is part of the webkitgtk-2.4.11_5 package) - i recompiled webkitgtk-2.4.11_5 with an 8MB stack to see if that fixed the issue, but haven't actually tested that fix yet. will post here if there's any progress.
nmeum at Tue, 05 Jun 2018 00:46:26 -0700
> i recompiled webkitgtk-2.4.11_5 with an 8MB stack to see if that fixed the issue, but haven't actually tested that fix yet. will post here if there's any progress. Any updates on this?
ds6 at Thu, 12 Jul 2018 23:19:42 -0700
if this is still a problem, the Gentoo patchset works fine for Alpine Linux (after some minor adjustments). it _should_ apply cleanly to 2.20.3, not sure about later versions. https://github.com/luakit/luakit/issues/550#issuecomment-404734722 http://tpaste.us/9KlP
Jürgen Buchmüller at Sat, 14 Jul 2018 10:06:07 -0700
Thanks @ds6 ! I'll try it locally with an updated `webkit2gtk-2.20.3`. I'd be glad to see it fixes the musl problems.
nmeum at Mon, 16 Jul 2018 09:27:22 -0700
There is also an [upstream issue regarding this problem](https://bugs.webkit.org/show_bug.cgi?id=187485) maybe someone should tell them about the gentoo patch (I don't have an account in their bugzilla instance).