Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 920704 - net-libs/webkit-gtk-2.42.4-r410: assert 2 ** math.log(memoryBits, 2) == memoryBits AssertionError
Summary: net-libs/webkit-gtk-2.42.4-r410: assert 2 ** math.log(memoryBits, 2) == memor...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL: https://github.com/WebKit/WebKit/pull...
Whiteboard:
Keywords:
: 832006 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-12-25 21:08 UTC by Conrad Kostecki
Modified: 2024-04-13 15:51 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log.gz (build.log.gz,41.52 KB, application/gzip)
2023-12-25 21:09 UTC, Conrad Kostecki
Details
memorybits.patch (memorybits.patch,417 bytes, text/plain)
2023-12-29 22:19 UTC, Conrad Kostecki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Conrad Kostecki gentoo-dev 2023-12-25 21:08:05 UTC
[1317/6875] cd /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4_build/Source/JavaScriptCore && /usr/bin/python3.12 /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/wasm.json /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4_build/JavaScriptCore/DerivedSources/WasmOps.h
FAILED: JavaScriptCore/DerivedSources/WasmOps.h /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4_build/JavaScriptCore/DerivedSources/WasmOps.h
cd /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4_build/Source/JavaScriptCore && /usr/bin/python3.12 /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/wasm.json /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4_build/JavaScriptCore/DerivedSources/WasmOps.h
Traceback (most recent call last):
  File "/var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py", line 212, in <module>
    memoryLog2AlignmentLoads = memoryLog2AlignmentGenerator(lambda op: (op["category"] == "memory" and len(op["return"]) == 1))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py", line 201, in memoryLog2AlignmentGenerator
    result.append("    case " + wasm.toCpp(op["name"]) + ": return " + memoryLog2Alignment(op) + ";")
                                                                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/generateWasm.py", line 139, in memoryLog2Alignment
    assert 2 ** math.log(memoryBits, 2) == memoryBits
AssertionError
Comment 1 Conrad Kostecki gentoo-dev 2023-12-25 21:09:24 UTC
Created attachment 880307 [details]
build.log.gz
Comment 2 Conrad Kostecki gentoo-dev 2023-12-25 21:09:41 UTC
Portage 3.0.58 (python 3.11.7-final-0, default/linux/amd64/17.1/desktop, gcc-13, glibc-2.38-r7, 6.6.8-gentoo x86_64)
=================================================================
System uname: Linux-6.6.8-gentoo-x86_64-Intel-R-_Core-TM-_i7-6600U_CPU_@_2.60GHz-with-glibc2.38
KiB Mem:    32581056 total,  28105112 free
KiB Swap:   34078716 total,  34078716 free
Timestamp of repository gentoo: Mon, 25 Dec 2023 18:15:01 +0000
Head commit of repository gentoo: 3e2462df7e5a74998f0fb001e8b609e7a4540012
sh bash 5.2_p21-r1
ld GNU ld (Gentoo 2.41 p4) 2.41.0
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p21-r1::gentoo
dev-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2-r1::gentoo
dev-lang/python:           3.11.7::gentoo, 3.12.1_p1::gentoo
dev-lang/rust-bin:         1.74.1::gentoo
dev-util/cmake:            3.28.1::gentoo
dev-util/meson:            1.3.0-r2::gentoo
sys-apps/baselayout:       2.14-r1::gentoo
sys-apps/openrc:           0.52.1::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/autoconf:        2.13-r8::gentoo, 2.72-r1::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils:        2.41-r3::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r3::gentoo, 17.0.6::gentoo
sys-devel/gcc:             13.2.1_p20231216::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             15.0.7::gentoo, 17.0.6::gentoo
sys-devel/llvm:            15.0.7-r3::gentoo, 17.0.6::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.6::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r7::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.de.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-extra-opts: --compress --exclude-from=/etc/portage/rsync_excludes --new-compress
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1

serenity
    location: /usr/local/portage
    masters: gentoo
    volatile: True

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -mfpmath=sse,387 -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -mfpmath=sse,387 -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe -fvisibility-inlines-hidden"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--autounmask=y --quiet-build=n --with-bdeps=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-march=native -mfpmath=sse,387 -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms sign strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync warn-on-large-env xattr"
FFLAGS="-march=native -mfpmath=sse,387 -O3 -frecord-gcc-switches -fomit-frame-pointer -malign-data=abi -mtls-dialect=gnu2 -pipe"
GENTOO_MIRRORS="https://packages.hetzner.com/gentoo/"
INSTALL_MASK="/etc/systemd/* /etc/xinetd.d/* /usr/lib/systemd/*"
LANG="de_DE.UTF-8"
LC_ALL="de_DE.UTF-8"
LDFLAGS="-Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-O1 -Wl,--sort-common -Wl,-z,now"
LEX="flex"
LINGUAS="de de_DE"
MAKEOPTS="-j5 -l4"
PKGDIR="/var/cache/binpkgs"
PORTAGE_BUNZIP2_COMMAND="pbunzip2"
PORTAGE_BZIP2_COMMAND="pbzip2"
PORTAGE_COMPRESS="xz"
PORTAGE_COMPRESS_FLAGS="-9e"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_EXTRA_OPTS="--compress --exclude-from=/etc/portage/rsync_excludes --new-compress"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="X aalib accessibility acl alsa amd64 appindicator asm avif bash-completion berkdb bluetooth brotli bzip2 cairo caps cddb cjk colord crypt cups curl cvs cxx dbus dga dri dvb egl elogind encode exif fbcon ffmpeg filecaps flac fontconfig fortran ftp gd gdbm geolocation gif git gles2 gmp gnome-keyring gnutls gphoto2 gpm gsm gstreamer gtk gui iconv icu idn ieee1394 imap imlib inotify introspection ipv6 java javascript jbig jemalloc jit joystick jpeg jpeg2k keyring latex lcms ldap libass libcaca libnotify libsamplerate lm-sensors lto lua luajit lz4 lzma lzo mad magic mhash mikmod milter modplug mp3 ncurses networkmanager nls nntp offensive ogg openal opencl openexr opengl openmp opus orc oss pam pcre pdf perl pie png policykit postscript pulseaudio python qt6 readline rtmp samba sasl scanner screencast sctp sdl seccomp slang smartcard sndfile snmp socks5 sound sox speex spell split-usr sqlite ssl startup-notification subversion suid svg symlink syslog test-rust theora threads tiff truetype udev unicode upnp usb v4l vaapi vdpau verify-sig vim-syntax vnc vorbis vulkan wavpack wayland webkit webp wifi x264 xattr xface xft xinetd xml xpm xscreensaver xv xvid zeroconf zip zlib zstd" ABI_X86="32 64" COLLECTD_PLUGINS="apcups battery buddyinfo capabilities cgroups check_uptime connectivity conntrack contextswitch cpu cpufreq cpusleep df disk dns entropy ethstat exec fhcount filecount hddtemp hugepages interface ipc ipmi iptables irq load java mcelog md memory mysql netlink nfs nginx ntpd openldap openvpn pcie_errors ping postgresql processes procevent protocols rrdcached sensors serial smart snmp swap syslog tcpconns thermal turbostat unixsock uptime users wireless" CPU_FLAGS_X86="aes avx avx2 rdrand mmx mmxext sse sse2 sse3 sse4_1 sse4_2 ssse3" CURL_SSL="openssl" ELIBC="glibc" GPSD_PROTOCOLS="garmin garmintxt nmea0183" GRUB_PLATFORMS="pc" INPUT_DEVICES="libinput synaptics" KERNEL="linux" L10N="de de_DE" LCD_DEVICES="cfontzpacket crystalfontz glcd2usb hd44780 lcd2usb" LUA_SINGLE_TARGET="lua5-3" LUA_TARGETS="lua5-3 lua5-4" NGINX_MODULES_HTTP="access addition auth_basic autoindex brotli browser charset fancyindex fastcgi geo geoip geoip2 gunzip gzip gzip_static headers_more image_filter javascript limit_conn limit_req map metrics proxy realip referer rewrite secure_link sticky stub_status upload_progress upstream_keepalive vhost_traffic_status xslt" NGINX_MODULES_MAIL="imap pop3 smtp" NGINX_MODULES_STREAM="access geo geoip geoip2 javascript limit_conn map realip return ssl_preread" PHP_TARGETS="php7-4 php8-1" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11 python3_12" RUBY_TARGETS="ruby31 ruby32" SANE_BACKENDS="hp net" VIDEO_CARDS="intel"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 3 Conrad Kostecki gentoo-dev 2023-12-25 21:10:16 UTC
[ebuild  N     ] net-libs/webkit-gtk-2.42.4-r410:4.1/0::gentoo  USE="X avif gamepad gstreamer introspection jpeg2k jpegxl jumbo-build keyring lcms pdf (seccomp) spell wayland (-aqua) -examples -systemd" 0 KiB
Comment 4 Mart Raudsepp gentoo-dev 2023-12-25 22:02:11 UTC
I don't see anything changed in this area, nor does it fail for me and many others (I haven't tried on amd64 personally though).
What was the previous webkit-gtk version that built fine on that machine?
Are you able to poke at it a bit more from your end?
For example I can't spot what the value of memoryBits is when it fails assert, looks like python doesn't include that information in the output? :(  Can you find out and poke at it a bit?
Comment 5 Conrad Kostecki gentoo-dev 2023-12-25 22:24:13 UTC
(In reply to Mart Raudsepp from comment #4)
> What was the previous webkit-gtk version that built fine on that machine?

None. This is basically a fresh gentoo install. But not fully true. This installation is about 1 year old and lacked now about 8 month of updates. But bare metal, not many packages installed. I emerged all updates and all went fine. But running full in ~testing.

Now I wanted to install evolution as package, which wants to pull in webkit-gtk.

> Are you able to poke at it a bit more from your end?
> For example I can't spot what the value of memoryBits is when it fails
> assert, looks like python doesn't include that information in the output? :(
> Can you find out and poke at it a bit?

Can you guide me a little bit here? I am not sure, how to get those information, but I am happy to try.

Running the command "/usr/bin/python3.12 /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4/Source/JavaScriptCore/wasm/wasm.json /var/tmp/portage/net-libs/webkit-gtk-2.42.4-r410/work/webkitgtk-2.42.4_build/JavaScriptCore/DerivedSources/WasmOps.h" reproduces the error manually.
Comment 6 Conrad Kostecki gentoo-dev 2023-12-25 22:29:14 UTC
(In reply to Mart Raudsepp from comment #4)
> For example I can't spot what the value of memoryBits is when it fails

memoryBits is 8 according to my added log output.
Comment 7 Conrad Kostecki gentoo-dev 2023-12-25 22:43:08 UTC
str(float(memoryBits))) = 8.0
str(float(math.log(memoryBits, 2)))) = 3.0
str(float(2 ** math.log(memoryBits, 2)))) = 7.999999999999999
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-12-26 17:52:32 UTC
-mfpmath=sse,387 is a bit unusual. Normally people just set sse. I think (but not 100% sure) that sse is implied by x86-64 but not 100% sure (for mfpmath purposes). Need to check.
Comment 9 Conrad Kostecki gentoo-dev 2023-12-26 20:28:51 UTC
(In reply to Sam James from comment #8)
> -mfpmath=sse,387 is a bit unusual. Normally people just set sse. I think
> (but not 100% sure) that sse is implied by x86-64 but not 100% sure (for
> mfpmath purposes). Need to check.

At least compiling python with CFLAGS="-march=native -O2 -pipe" does not change anything for me while calling those math functions directly in the interpreter.
Comment 10 Conrad Kostecki gentoo-dev 2023-12-29 17:55:54 UTC
>>> 2 ** 3.0
7.999999999999999

>>> 2 ** 3
8

I am confused. Anyone an explanation or idea how to debug this further?
Comment 11 Conrad Kostecki gentoo-dev 2023-12-29 22:19:00 UTC
Created attachment 880969 [details]
memorybits.patch

This quick & dirty patch fixes it for me..
Comment 12 Mart Raudsepp gentoo-dev 2023-12-29 22:41:21 UTC
This doesn't even seem all that wrong to me. memorybits is an integer, etc.
Could you file a PR to WebKit with the commit message or at least PR message explaining the problem and see what happens as feedback?

Something like I did in https://github.com/WebKit/WebKit/pull/19242 perhaps.
I remember to poke that now, so if they move it ahead, the commit will probably get rewritten. You can see the original formatting of the commit message they seem to want in net-libs/webkit-gtk/files/2.42.1-arm64-non-jumbo-fix.patch and there's https://github.com/WebKit/WebKit/wiki/Pull-Requests
Comment 13 Mart Raudsepp gentoo-dev 2023-12-29 23:41:39 UTC
Thinking on this further - I don't understand the purpose of the assert at all anymore. 2 ** x and log(x, 2) are inverse operations, barring IEE 754 math issues, this assert is guaranteed to succeed. The only case where it wouldn't pass is if python core math library is broken for one of them (unlikely), or the case you are hitting (very likely apparently; and it happens for the value of 5 for me, for example).

This was added in https://github.com/WebKit/WebKit/commit/5ba399a221ec38686323efecb0043703bebb659e
Comment 14 Mart Raudsepp gentoo-dev 2023-12-29 23:44:21 UTC
https://bugs.webkit.org/show_bug.cgi?id=168836

So the purpose was to check that memoryBits is a power of 2, which the assert doesn't do?
Comment 15 Conrad Kostecki gentoo-dev 2023-12-30 11:12:12 UTC
(In reply to Mart Raudsepp from comment #12)
> This doesn't even seem all that wrong to me. memorybits is an integer, etc.

I still don't understand, why "3.0" produces a different result than "3".

> Could you file a PR to WebKit with the commit message or at least PR message
> explaining the problem and see what happens as feedback?

Yes, I can do that. Fill on their Github? Do you would be willing to include such patch? Based on your example, I don't think, that there will be soon (tm) a fix.

(In reply to Mart Raudsepp from comment #13)
> Thinking on this further - I don't understand the purpose of the assert at
> all anymore. 2 ** x and log(x, 2) are inverse operations, barring IEE 754
> math issues, this assert is guaranteed to succeed. The only case where it
> wouldn't pass is if python core math library is broken for one of them
> (unlikely), or the case you are hitting (very likely apparently; and it
> happens for the value of 5 for me, for example).

It looks like, that all values with .0 seems to produece that, even 5.

>>> 2 ** 5
32

>>> 2 ** 5.0
31.999999999999996

(In reply to Mart Raudsepp from comment #14)
> So the purpose was to check that memoryBits is a power of 2, which the
> assert doesn't do?

What do you mean?
Comment 16 Conrad Kostecki gentoo-dev 2023-12-30 11:42:07 UTC
I do wonder, but with the following proramm, the glibc (?) also seems produce wrongly results.

 #include <stdio.h>
#include <math.h>

int main()
{
    double x = 2.0; // base
    double y = 3.0;  // power

    // using the pow() function
    double ans = pow(x, y);
    
    // printing the output
    printf("%.15f\n", ans);

    return 0;
}

$  ./a.out 
7.999999999999999
Comment 17 Larry the Git Cow gentoo-dev 2024-01-03 21:59:07 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c1b610a5a12b7954708038906c87c0a69768f254

commit c1b610a5a12b7954708038906c87c0a69768f254
Author:     Mart Raudsepp <leio@gentoo.org>
AuthorDate: 2024-01-03 21:42:04 +0000
Commit:     Mart Raudsepp <leio@gentoo.org>
CommitDate: 2024-01-03 21:58:32 +0000

    net-libs/webkit-gtk: fix build failing assert on some machines
    
    Closes: https://bugs.gentoo.org/920704
    Signed-off-by: Mart Raudsepp <leio@gentoo.org>

 .../webkit-gtk/files/2.42.4-wasm-assert-fix.patch  | 53 ++++++++++++++++++++++
 net-libs/webkit-gtk/webkit-gtk-2.42.4-r410.ebuild  |  4 +-
 net-libs/webkit-gtk/webkit-gtk-2.42.4-r600.ebuild  |  4 +-
 net-libs/webkit-gtk/webkit-gtk-2.42.4.ebuild       |  4 +-
 4 files changed, 62 insertions(+), 3 deletions(-)
Comment 18 Mart Raudsepp gentoo-dev 2024-04-13 15:51:46 UTC
*** Bug 832006 has been marked as a duplicate of this bug. ***