Skip to content

Fix HAVE_POSIX_MEMALIGN not being defined - #355

Merged
SChernykh merged 1 commit into
tevador:masterfrom
thomasbuilds:fix-posix-memalign
Oct 15, 2026
Merged

SChernykh merged 1 commit into
tevador:masterfrom
thomasbuilds:fix-posix-memalign

Conversation

@thomasbuilds

Copy link
Copy Markdown
Contributor

The posix_memalign check added in #317 only sets a CMake variable so HAVE_POSIX_MEMALIGN is never defined and rx_aligned_alloc still falls back to malloc in the portable fallback of intrin_portable.h (RISC-V, s390x, 32-bit ARM, ...). The cache, dataset, scratchpad and VM then only get malloc's alignment instead of 64 bytes. With -fsanitize=alignment on RISC-V, randomx-benchmark --verify --jit --softAes --threads 2 reports:

src/randomx.cpp:247:53: runtime error: constructor call on misaligned address 0x5555555f1610 for type 'struct CompiledLightVmDefault', which requires 64 byte alignment

On 32-bit ARM, glibc's malloc only guarantees 8-byte alignment, and Clang's NEON code in randomx_vm::initialize() (vld1.64 {d18, d19}, [r1:128]!) crashes with SIGBUS when the VM is not 16-byte aligned.

This defines it when the check passes, as is done for HAVE_HWCAP.

@SChernykh
SChernykh merged commit 8a13070 into tevador:master Oct 15, 2026
10 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants