Skip to content

Fix crash on x86 CPUs without AES support in clang-cl builds - #1

Merged
jedisct1 merged 1 commit into
hiae-aead:mainfrom
jedisct1:clang-cl-dispatch
Sep 14, 2026
Merged

jedisct1 merged 1 commit into
hiae-aead:mainfrom
jedisct1:clang-cl-dispatch

Conversation

@jedisct1

@jedisct1 jedisct1 commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

When the library is built with clang-cl, it could end up using an implementation that relies on AES instructions even on a CPU that doesn't have them. The first call then crashes. This was reported against a shipping Windows build.

The cause was that different source files disagreed about whether the plain software version had been built, so the code that picks an implementation didn't know it was there, and fell back to assuming AES was always available. The CPU check itself was correct, its answer was just ignored.

This reorganizes things the way libaegis already does it: the compiler and CPU checks live in one shared header that every file uses, so they all agree, and an implementation is only picked when the CPU really supports it. Having the two projects match should make both easier to maintain.

It also lets clang-cl use the fastest HiAE implementation, which was turned off for it with no real reason, and adds a clang-cl build to CI so this doesn't come back.

Tested on Linux with the normal build and with AES/AVX-512 enabled at compile time, plus the single-file amalgamated build. All tests pass and forcing the software implementation still works.

When built with clang-cl, the library could pick an implementation that
uses AES instructions even on a CPU that doesn't have them, which crashes
on the first call. It happened because different source files disagreed
about whether the plain software version was available, and the picker had
a fallback that assumed AES was always present.

This reorganizes the code the same way libaegis does it: the compiler and
CPU checks now live in one shared header that every file uses, so they all
agree, and an implementation is only chosen when the CPU really supports
it. Keeping the two projects consistent should make them easier to
maintain.

Also lets clang-cl use the fastest HiAE implementation, which was
needlessly turned off for it, and adds a clang-cl build to CI.
@jedisct1 jedisct1 changed the title Port libaegis dispatch structure; fix clang-cl implementation selection Fix crash on x86 CPUs without AES support in clang-cl builds Sep 14, 2026
@jedisct1
jedisct1 merged commit 4e5771f into hiae-aead:main Sep 14, 2026
6 checks passed
@jedisct1
jedisct1 deleted the clang-cl-dispatch branch September 14, 2026 18:58
@jedisct1

Copy link
Copy Markdown
Collaborator Author

AI slop made by Perplexity Computer while I was AFK but it doesn't touch any of the crypto implementations.

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.

1 participant