Bug 2323980

Summary: s390x support incomplete: luajit-2.1/jit/bcsave.lua:243: assertion failed!
Product: [Fedora] Fedora Reporter: Petr Menšík <pemensik>
Component: luajitAssignee: Andreas Schneider <asn>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: aleksei.nikiforov, asn, dan, epel-packagers-sig, igor.raits, iii, mcepl, sipoyare
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: luajit-2.1.1731485912-3.fc42 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-11-14 15:38:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2222911    
Bug Blocks: 2323979    

Description Petr Menšík 2024-11-05 19:12:28 UTC
luajit: /usr/share/luajit-2.1/jit/bcsave.lua:243: assertion failed!

Reproducible: Always

Steps to Reproduce:
1. Try to compile https://github.com/DNS-OARC/dnsjit on s390x
2. Because build system error it skips assertion fails for every file.
3. But terminates on missing files, like /usr/bin/ld: cannot find core/compat.luaho: No such file or directory
Actual Results:  
make[3]: Entering directory '/builddir/build/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'
/usr/bin/luajit -bg -n "dnsjit.`echo \"core/compat.luaho\" | sed 's%\..*%%' | sed 's%/%.%g'`_h" -t o "core/compat.luah" "core/compat.luaho"
/usr/bin/luajit: /usr/share/luajit-2.1/jit/bcsave.lua:243: assertion failed!
make[3]: Leaving directory '/builddir/build/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'
make[3]: Entering directory '/builddir/build/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'
/usr/bin/luajit -bg -n "dnsjit.`echo \"core/channel.luaho\" | sed 's%\..*%%' | sed 's%/%.%g'`_h" -t o "core/channel.luah" "core/channel.luaho"
/usr/bin/luajit: /usr/share/luajit-2.1/jit/bcsave.lua:243: assertion failed!
make[3]: Leaving directory '/builddir/build/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'

Expected Results:  
Builds also on s390x

Comment 1 Dan Horák 2024-11-05 19:24:27 UTC
Petr, please report this issue upstream into https://github.com/LuaJIT/LuaJIT/pull/631 where IBM is maintaining the s390x port.

Comment 2 Petr Menšík 2024-11-05 20:24:50 UTC
Done in the mean time :)

Failed scratch build: https://koji.fedoraproject.org/koji/taskinfo?taskID=125532998

One of issues is created assertion failed did not break make process. It happened on much more files than I posted here.

Comment 3 Petr Menšík 2024-11-05 20:35:57 UTC
Commented on: https://github.com/LuaJIT/LuaJIT/pull/631#issuecomment-2458078928

Comment 4 Dan Horák 2024-11-06 12:42:16 UTC
I have retried the build with luajit updated to latest upstream luajit with latest s390x patch and the issue is still there

dnsjit source rpm = https://kojipkgs.fedoraproject.org//work/tasks/2967/125532967/dnsjit-1.4.0-2.fc42.src.rpm (from Petr's scratch build)

...
make[3]: Leaving directory '/root/rpmbuild/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'
make[3]: Entering directory '/root/rpmbuild/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'
/usr/bin/luajit -bg -n "dnsjit.`echo \"core/compat.luaho\" | sed 's%\..*%%' | sed 's%/%.%g'`_h" -t o "core/compat.luah" "core/compat.luaho"
/usr/bin/luajit: /usr/share/luajit-2.1/jit/bcsave.lua:243: assertion failed!
make[3]: Leaving directory '/root/rpmbuild/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'
make[3]: Entering directory '/root/rpmbuild/BUILD/dnsjit-1.4.0-build/dnsjit-1.4.0/src'
...
...
libtool: link: gcc -Werror=attributes -I. -I.. -I../include -I/usr/include/luajit-2.1 -I/usr/include/p11-kit-1 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=z13 -mtune=z14 -fasynchronous-unwind-tables -fstack-clash-protection -D__s390x__ -I/usr/include/ck -Wl,-E -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -o dnsjit dnsjit.o globals.o core/channel.o core/compat.o core/file.o core/log.o core/object.o core/object/dns.o core/object/ether.o core/object/gre.o core/object/icmp6.o core/object/icmp.o core/object/ieee802.o core/object/ip6.o core/object/ip.o core/object/linuxsll.o core/object/loop.o core/object/null.o core/object/payload.o core/object/pcap.o core/object/tcp.o core/object/udp.o core/producer.o core/receiver.o core/thread.o filter/copy.o filter/ipsplit.o filter/layer.o filter/split.o filter/timing.o input/fpcap.o input/mmpcap.o input/pcap.o input/zmmpcap.o input/zpcap.o lib/base64url.o lib/clock.o lib/trie.o output/dnscli.o output/pcap.o output/respdiff.o output/tcpcli.o output/tlscli.o output/udpcli.o core/compat.luaho core/channel.luaho core/file.luaho core/log.luaho core/object/dns.luaho core/object/ether.luaho core/object/gre.luaho core/object/icmp6.luaho core/object/icmp.luaho core/object/ieee802.luaho core/object/ip6.luaho core/object/ip.luaho core/object/linuxsll.luaho core/object/loop.luaho core/object.luaho core/object/null.luaho core/object/payload.luaho core/object/pcap.luaho core/object/tcp.luaho core/object/udp.luaho core/producer.luaho core/receiver.luaho core/thread.luaho core/timespec.luaho filter/copy.luaho filter/ipsplit.luaho filter/layer.luaho filter/split.luaho filter/timing.luaho input/fpcap.luaho input/mmpcap.luaho input/pcap.luaho input/zmmpcap.luaho input/zpcap.luaho lib/base64url.luaho lib/clock.luaho lib/trie.luaho output/dnscli.luaho output/pcap.luaho output/respdiff.luaho output/tcpcli.luaho output/tlscli.luaho output/udpcli.luaho core.luao lib.luao input.luao filter.luao output.luao core/channel.luao core/compat.luao core/file.luao core/loader.luao core/log.luao core/object/dns/label.luao core/object/dns.luao core/object/dns/q.luao core/object/dns/rr.luao core/object/ether.luao core/object/gre.luao core/object/icmp6.luao core/object/icmp.luao core/object/ieee802.luao core/object/ip6.luao core/object/ip.luao core/object/linuxsll.luao core/object/loop.luao core/object.luao core/object/null.luao core/object/payload.luao core/object/pcap.luao core/objects.luao core/object/tcp.luao core/object/udp.luao core/producer.luao core/receiver.luao core/thread.luao core/timespec.luao filter/copy.luao filter/ipsplit.luao filter/layer.luao filter/split.luao filter/timing.luao input/fpcap.luao input/mmpcap.luao input/pcap.luao input/zero.luao input/zmmpcap.luao input/zpcap.luao lib/base64url.luao lib/clock.luao lib/getopt.luao lib/ip.luao lib/parseconf.luao lib/trie/iter.luao lib/trie.luao lib/trie/node.luao output/dnscli.luao output/null.luao output/pcap.luao output/respdiff.luao output/tcpcli.luao output/tlscli.luao output/udpcli.luao  -lpthread -lluajit-5.1 -llz4 -lzstd -lpcap -lgnutls -llzma -lz -llmdb -lck -pthread
/usr/bin/ld: cannot find core/compat.luaho: No such file or directory
/usr/bin/ld: cannot find core/channel.luaho: No such file or directory
...

the assertion repeats many time, same with the "no such file", which is a consequence of the assertion I believe

Comment 5 Dan Horák 2024-11-06 12:48:19 UTC
IMO an s390x entry is missing in https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/jit/bcsave.lua#L91

Comment 6 Dan Horák 2024-11-06 12:55:34 UTC
and

--- bcsave.lua.orig	2024-11-06 13:53:07.273746106 +0100
+++ bcsave.lua	2024-11-06 13:50:53.023746106 +0100
@@ -101,6 +101,7 @@
   mips64el =	{ e = "le", b = 64, m = 8, f = 0x80000007, },
   mips64r6 =	{ e = "be", b = 64, m = 8, f = 0xa0000407, },
   mips64r6el =	{ e = "le", b = 64, m = 8, f = 0xa0000407, },
+  s390x =       { e = "be", b = 64, m = 22, },
 }
 
 local map_os = {


seems to fix the issue. There is "FAIL: test-ipsplit.sh" in the dnsjit test-suite later in the build.

Comment 7 Aleksei Nikiforov 2024-11-06 14:49:49 UTC
I took a look at test-ipsplit.sh on s390x. It looks like an endianness issue in dnsjit test.

For test they overwrite part of ipv6 address here:
https://github.com/DNS-OARC/dnsjit/blob/develop/src/filter/ipsplit.c#L206
> memcpy(&ip6->dst, client->id, sizeof(client->id));

It's overwritten in host endianness as number.

And then it's converted to string and expected as little endian:
https://github.com/DNS-OARC/dnsjit/blob/develop/src/test/test_ipsplit.lua#L84
> assert(ip_pkt(obj):destination() == "0100:0000:0000:0000:0000:0000:0000:0001")
On s390x result is actually "0000:0001:0000:0000:0000:0000:0000:0001".

Same goes for next checks for destination address.

Comment 8 Fedora Update System 2024-11-14 15:34:18 UTC
FEDORA-2024-914c9f2826 (luajit-2.1.1731485912-3.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-914c9f2826

Comment 9 Fedora Update System 2024-11-14 15:38:26 UTC
FEDORA-2024-914c9f2826 (luajit-2.1.1731485912-3.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.