Bug 278290 - emulators/qemu-user-static: ruby33 crashes under amd64->arm64 emulation
Summary: emulators/qemu-user-static: ruby33 crashes under amd64->arm64 emulation
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-emulation (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-10 14:53 UTC by John F. Carr
Modified: 2024-04-11 00:21 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (emulation)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John F. Carr 2024-04-10 14:53:35 UTC
I have a repeatable crash using qemu emulation to cross compile amd64 to arm64 using poudriere and qemu.  While building rubygem-asciidoctor the emulated ruby33 and native qemu both dump core.  This is on 15.0-CURRENT running inside bhyve.

I have overridden some default versions.

RUBY_DEFAULT=3.3
LLVM_DEFAULT=18

Host /etc/make.conf sets CPUTYPE?=znver1.  Target poudriere.d/make.conf sets CPUTYPE?=cortex-a53.

The log says.

=> SHA256 Checksum OK for rubygem/asciidoctor-2.0.22.gem.
Unpacked gem: '/wrkdirs/usr/ports/textproc/rubygem-asciidoctor/work/asciidoctor-2.0.22'
<jemalloc>: jemalloc_rtree.c:205: Failed assertion: "!dependent || leaf != NULL"
*** Signal 6

There are two core dumps.

# ls -ldh *core
-r--r--r--  1 root 6001  1.0G Apr 10 14:26 qemu-aarch64-static.core
-rw-r--r--  1 root 6001   20K Apr 10 14:26 qemu_ruby33.core
# file *core
qemu-aarch64-static.core: ELF 64-bit LSB core file, x86-64, version 1 (FreeBSD), FreeBSD-style, from '/usr/local/bin/qemu-aarch64-static /usr/local/bin/ruby33 /usr/local/bin/gem unpa', pid=42031
qemu_ruby33.core:         ELF 64-bit LSB core file, ARM aarch64, version 1 (FreeBSD), can't read elf program headers at 20616

The qemu core has no usable symbols and I don't know how to debug the arm64 core on an amd64 host.  I can run again with whatever debugging settings seem useful.

(lldb) bt
* thread #1, name = 'qemu-aarch64-static', stop reason = signal SIGSEGV
  * frame #0: 0x00000000605f1a4a qemu-aarch64-static`___lldb_unnamed_symbol12822 + 282
    frame #1: 0x0000000060320db7 qemu-aarch64-static`___lldb_unnamed_symbol1691 + 71
    frame #2: 0x000000006030cef6 qemu-aarch64-static`___lldb_unnamed_symbol1329 + 3734
    frame #3: 0x000000006030f197 qemu-aarch64-static`___lldb_unnamed_symbol1365 + 135
    frame #4: 0x00000000603106b9 qemu-aarch64-static`___lldb_unnamed_symbol1372 + 1481
    frame #5: 0x0000000060308f5d qemu-aarch64-static`___lldb_unnamed_symbol1313 + 157
    frame #6: 0x0000000060309f33 qemu-aarch64-static`___lldb_unnamed_symbol1320 + 2931
    frame #7: 0x0000000060572b48 qemu-aarch64-static`___lldb_unnamed_symbol10704 + 280
    frame #8: 0x000000006029e110 qemu-aarch64-static`___lldb_unnamed_symbol1 + 48
(lldb) x/i $pc
x/i $pc
->  0x605f1a4a: f3 48 a5  other       rep    movsq	(%rsi), %es:(%rdi)
(lldb) register read
General Purpose Registers:
       rax = 0x0000000880938f90
       rbx = 0x0000000000001000
       rcx = 0x0000000000000200
       rdx = 0x0000000000001000
       rdi = 0x0000000880938f90
       rsi = 0x00007fffe07c3000
       rbp = 0x0000000880938a10
       rsp = 0x00000008809389e8
        r8 = 0xffff8008a0175f90
        r9 = 0x0000000000000000
       r10 = 0x0000000000000000
       r11 = 0x0000000000000246
       r12 = 0x0000000000016000
       r13 = 0x0000000880938b08
       r14 = 0x00007fffe07c3000
       r15 = 0x0000000880938f90
       rip = 0x00000000605f1a4a  qemu-aarch64-static`___lldb_unnamed_symbol12822 + 282
    rflags = 0x0000000000010216
        cs = 0x0000000000000043
        fs = 0x0013
        gs = 0x001b
        ss = 0x000000000000003b
        ds = 0x003b
        es = 0x003b

(lldb) p (char *)$rdi
(char *) 0x0000000880938f90 "\U0000007fELF\U00000002\U00000001\U00000001\t"
(lldb) x/8g $rdi
0x880938f90: 0x09010102464c457f 0x0000000000000000
0x880938fa0: 0x0000000100b70003 0x0000000000000000
0x880938fb0: 0x0000000000000040 0x0000000000001280
0x880938fc0: 0x0038004000000000 0x001a001b0040000a

The memory addressed by $rsi is unreadable, as is the previous page ($rsi - 8).
Comment 1 John F. Carr 2024-04-10 15:04:19 UTC
This is the failing shell command, with /tmp/work being any scratch directory you like.  Run it in in a qemu-emulated arm64 world with ruby 3.3 installed.

# gem unpack --target=/tmp/work /distfiles/rubygem/asciidoctor-2.0.22.gem
Unpacked gem: '/tmp/work/asciidoctor-2.0.22'
<jemalloc>: jemalloc_rtree.c:205: Failed assertion: "!dependent || leaf != NULL"
Segmentation fault (core dumped)