Skip to content

Fix stale native cache serving AVX build on CPUs without AVX (#401)#406

Merged
kdroidFilter merged 1 commit into
masterfrom
fix/avx-stale-native-cache
Jun 17, 2026
Merged

Fix stale native cache serving AVX build on CPUs without AVX (#401)#406
kdroidFilter merged 1 commit into
masterfrom
fix/avx-stale-native-cache

Conversation

@kdroidFilter

Copy link
Copy Markdown
Owner

Summary

Closes the persistent crash reports on issue #401. Removing /arch:AVX2 (v1.3.1) already produces an AVX-free WinTray.dll, but users kept crashing after upgrading because of a stale native library cache.

  • NativeLibraryLoader validated its persistent cache (%LOCALAPPDATA%\composetray\native\…) by file size only.
  • The AVX and SSE2 builds of WinTray.dll are byte-for-byte the same size (23552 bytes), only the content differs (10 AVX instructions vs 0 — verified by disassembling the published v1.3.0 / v1.3.1 artifacts).
  • So after upgrading, the loader reused the stale AVX library on disk and EXCEPTION_ILLEGAL_INSTRUCTION survived the fix on pre-2011 CPUs (Xeon E5520, Core 2 Duo).

Changes

  • NativeLibraryLoader: validate the cache by SHA-256 content hash instead of size (reuses the existing sha256 helpers, now internal).
  • CI guard (build-natives.yaml + CMakeLists.txt comment): disassemble the built x64 DLL and fail the build if any AVX instruction is present, so /arch:AVX* can never silently regress.
  • Add a jvmTest source set (the project had none) with a regression test.

Test plan

  • ./gradlew jvmTest — 3 tests pass; the key case asserts a same-size/different-content cache is treated as stale (the old size check would have accepted it).
  • ./gradlew ktlintCheck detekt — clean.
  • CI AVX guard runs on the Windows MSVC runner (validated locally by disassembling published artifacts: 10 AVX hits on v1.3.0, 0 on v1.3.1).

NativeLibraryLoader validated its persistent cache by file size only.
The AVX and SSE2 builds of WinTray.dll are both 23552 bytes, so after
upgrading from a build that crashed on pre-2011 CPUs (no AVX) the loader
kept serving the stale cached library and the crash survived the fix.

Validate the cache by SHA-256 content hash instead, and add a CI guard
that disassembles the built x64 DLL and fails if any AVX instruction is
present (issue #401).
@kdroidFilter kdroidFilter merged commit 03cd59a into master Jun 17, 2026
4 checks passed
@kdroidFilter kdroidFilter deleted the fix/avx-stale-native-cache branch June 17, 2026 19:39
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