x264enc: core on Intel CPUs with avx512. Missing memory alignment ?
Hello
I am using gtsreamer 1.18.2 built from source using meson, on a Centos 7.5. Everything is working as expected, except the x264 encoding on CPUs with avx512.
On these hosts, even this simple command line provoke a crash:
gst-launch-1.0 -v videotestsrc num-buffers=1000 ! x264enc qp-min=18 ! avimux ! filesink location=videotestsrc.avi
(gdb) where
#0 0x00007f7e2a778f3d in nanosleep () from /lib64/libpthread.so.0
#1 0x00007f7e2ac4bb58 in g_usleep () from /lib64/libglib-2.0.so.0
#2 0x0000000000404f0a in fault_spin () at ../subprojects/gstreamer/tools/gst-launch.c:131
#3 fault_handler_sighandler (signum=11) at ../subprojects/gstreamer/tools/gst-launch.c:112
#4 <signal handler called>
#5 0x00007f7e22047800 in x264_8_memcpy_aligned_avx512 () from /opt/gstreamer1.18/lib/libx264.so.160
#6 0x00007f7e2209ee5a in rd_cost_mb (h=h@entry=0x7f7e18083cc0, i_lambda2=921) at ../subprojects/x264/encoder/rdo.c:182
#7 0x00007f7e220af3e2 in intra_rd (h=h@entry=0x7f7e18083cc0, a=a@entry=0x7f7e1ea9d1a0, i_satd_thresh=i_satd_thresh@entry=268435456)
at ../subprojects/x264/encoder/analyse.c:991
#8 0x00007f7e220b166f in x264_8_macroblock_analyse (h=h@entry=0x7f7e18083cc0) at ../subprojects/x264/encoder/analyse.c:2941
#9 0x00007f7e220ea692 in slice_write (h=h@entry=0x7f7e18083cc0) at ../subprojects/x264/encoder/encoder.c:2786
#10 0x00007f7e220ecd7d in slices_write (h=0x7f7e18083cc0) at ../subprojects/x264/encoder/encoder.c:3127
#11 0x00007f7e220f7106 in threadpool_thread (pool=0x7f7e180283c0) at ../subprojects/x264/common/threadpool.c:69
#12 0x00007f7e2a771e25 in start_thread () from /lib64/libpthread.so.0
#13 0x00007f7e2a49bbad in clone () from /lib64/libc.so.6
When looking at the assembly code where it crashed :
>│0x7f7e22047800 <x264_8_memcpy_aligned_avx512+32> vmovdqa32 %zmm16,(%rdi,%rdx,1){%k1}
rdx 0x400 1024
rdi 0x7f7e1ea9cb20 140179657050912
=> rdi is not a multiple of 64, and AFAIK vmovdqa32 instruction requires a 64 bytes alignment
Is there something I can do to work around ? Other than adding "-Dx264:asm=disabled" ?
I tried to recompile gstreamer with "-Dmemory-alignment=64", but it did not help.