Skip to content

Fix RANDOMX_FLAG_HARD_AES crashing on CPUs without AES - #369

Open
thomasbuilds wants to merge 1 commit into
tevador:masterfrom
thomasbuilds:fix-hard-aes-crash
Open

thomasbuilds wants to merge 1 commit into
tevador:masterfrom
thomasbuilds:fix-hard-aes-crash

Conversation

@thomasbuilds

Copy link
Copy Markdown
Contributor

In default builds on x86-64 and ARM64 randomx_create_vm probes for hardware AES by executing an AES instruction. On a CPU without AES RANDOMX_FLAG_HARD_AES therefore makes it crash with an illegal instruction instead of returning NULL, which randomx.h documents for unsupported flags. randomx-benchmark hits this by default.

Where cpu.hasAes() is reliable (x86-64, and ARM64 on Linux and Apple), this checks it before the probe, as #349 does for RISC-V.

Comment thread src/virtual_machine.cpp
void VmBase<Allocator, softAes>::allocate() {
if (datasetPtr == nullptr)
throw std::invalid_argument("Cache/Dataset not set");
#ifdef __riscv

@hyc hyc Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not duplicate this code.

Use a single #if test, or do something like

#if (bunch of conditions)
#define HAVE_AES_CHECKER
#endif 
#ifdef HAVE_AES_CHECKER
...

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