Closed jirutka closed 1 month ago
Ah, that is not good. This is probably because the thread id is incorrect. Did you try to build with cmake ../.. -DMI_LIBC_MUSL=ON
? (this is a new switch in 1.8.6/2.1.6.). Let me know if that fixes things. Otherwise, we need to probably not use __builtin_thread_pointer
and make the test for that fail (I am guessing this is the case as the test fails on ARM).
Let me know if you can. Thanks!
Well, I managed to repro (inside a docker image on qemu) and somehow the error is caused by the meta data allocation inside a static array; I tried this on aarch64 and x86 (32-bit) and it works fine ... I do not quite understand why this fails with a BUS error (signal 7) on Alpine + MUSL + 32-bit ? For now, I "fixed" it by disabling fast meta data allocation and falling back to allocating OS memory instead but it would be best if I can understand the root cause. TBC :-)
note: you need to build with cmake ../.. -DMI_LIBC_MUSL=ON
; I will make that automatically once I figure out how to detect musl libc / alpine at cmake time.
Well, it turns out that the atomic write to the purge_expire
field (here) causes the BUS error if using a static array (while the OS allocated memory works somehow). If I make purge_expire
use a 32-bit value (instead of the 64-bit mi_msecs_t
) the BUS error disappears. The alignment seems right so I am not sure what is the cause -- maybe a bug in the implementation of 64-bit atomics?
edit: Even though mi_arena_static_zalloc
allocates to the right alignment, it turns out aligning the whole static array fixes the issue! I don't quite understand how this can be the case... but I will go ahead and push a fix.
I can confirm that 8fd1184272fdf5c93f4776a36086911b55fb315e fixed the problem – tests pass on all architectures now.
Tests have been failing on armhf and armv7 on Alpine Linux Edge (musl libc) since 2.1.4 and 1.8.4, including 2.1.6 and 1.8.6.
There’s no issue with 2.1.2 and 1.8.2.
Full log: https://gitlab.alpinelinux.org/alpine/aports/-/jobs/1384901