base64 icon indicating copy to clipboard operation
base64 copied to clipboard

Codec detection doesn’t work in test_base64 on musl libc

Open jirutka opened this issue 1 year ago • 3 comments

When I build v0.5.1 using cmake on Alpine Linux x86_64 (running in a VM), the tests (not just benchmark) fail on illegal instruction. However, the base64 utility works fine, so it seems that the detection is broken only in the tests? When I disable all AVX (-DBASE64_WITH_AVX512=OFF, -DBASE64_WITH_AVX2=OFF, -DBASE64_WITH_AVX=OFF), the tests pass.

I read related issues (#77, #95), but these are just about the benchmarks, not the tests.

./build/bin/test_base64
Codec AVX2:
The process was killed by SIGILL: Illegal instruction
strace ./build/bin/test_base64
execve("./build/bin/test_base64", ["./build/bin/test_base64"], 0x7fff8f113da0 /* 19 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7f07fcfafb08) = 0
set_tid_address(0x7f07fcfaff70)         = 16075
brk(NULL)                               = 0x55e997446000
brk(0x55e997448000)                     = 0x55e997448000
mmap(0x55e997446000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x55e997446000
open("build/bin/libbase64.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=84016, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 86016, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f07fcef9000
mmap(0x7f07fcefa000, 57344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0x1000) = 0x7f07fcefa000
mmap(0x7f07fcf08000, 16384, PROT_READ, MAP_PRIVATE|MAP_FIXED, 3, 0xf000) = 0x7f07fcf08000
mmap(0x7f07fcf0c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x12000) = 0x7f07fcf0c000
close(3)                                = 0
mprotect(0x7f07fcf0c000, 4096, PROT_READ) = 0
mprotect(0x7f07fcfac000, 4096, PROT_READ) = 0
mprotect(0x55e996638000, 4096, PROT_READ) = 0
ioctl(1, TIOCGWINSZ, {ws_row=77, ws_col=189, ws_xpixel=1701, ws_ypixel=1386}) = 0
writev(1, [{iov_base="Codec AVX2", iov_len=10}, {iov_base=":\n", iov_len=2}], 2Codec AVX2:
) = 12
--- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPN, si_addr=0x7f07fcf06c48} ---
+++ killed by SIGILL +++
The process was killed by SIGILL: Illegal instruction

jirutka avatar Nov 19 '23 19:11 jirutka

Does the VM support AVX2 instructions?

Runtime detection is done through CPU flags. Maybe the VM sets the CPU flags incorrectly for some reason?

aklomp avatar Nov 20 '23 13:11 aklomp

CI passes for the latest release for Alpine AMD64.

aklomp avatar Nov 20 '23 13:11 aklomp

There's no automatic feature detection in tests. Tests try to run what was built, even if unsupported (the base64 utility uses the dynamic/runtime dispatch & is thus unaffected). Maybe #145 could help (allows to disable some tests using environment variables).

mayeut avatar Jul 06 '24 10:07 mayeut