Repository navigation
Conversation
Built with gcc-13 primesieve 12.17 Linux ARM bottle crashes on a CPU without SVE, including primesieve 1000000 --count --threads=1 A register/disassembly capture shows cntb x9 executing in the baseline PreSieve::preSieve path even though its SVE runtime flag is false. More details in dimpase/homebrew-tap#111
|
Hi Dima, Thanks for the bug report. I was able to reproduce the bug on an AWS Graviton2 CPU on both Ubuntu 24.04 and Ubuntu 26.04. This crash is caused by a bug in GCC < 14 (tested with GCC 12 and 13); GCC 14 and later compile the code correctly. Even though this is a GCC bug, not a primesieve bug, I will still add a fix to primesieve (and primecount) to disable ARM SVE for GCC < 14. I will implement that fix in the // GCC < 14 inlines the ARM SVE functions into
// the non-SVE caller, which then crashes on
// CPUs without ARM SVE.
#if defined(__GNUC__) && \
!defined(__clang__) && \
__GNUC__ < 14
Error: ARM SVE multiarch requires GCC >= 14!
#endif |
|
On November 10, 2026 3:41:50 AM EST, Kim Walisch ***@***.***> wrote:
kimwalisch left a comment (kimwalisch/primesieve#201)
Hi Dima,
Thanks for the bug report.
I was able to reproduce the bug on an AWS Graviton2 CPU on both Ubuntu 24.04 and Ubuntu 26.04. This crash is caused by a bug in GCC < 14 (tested with GCC 12 and 13); GCC 14 and later compile the code correctly.
The problem is that GCC < 14 inlines functions marked as `__attribute__((target("+sve")))` which then causes SVE instructions to be executed on ARM CPUs without ARM SVE support.
Even though this is a GCC bug, not a primesieve bug, I will still add a fix to primesieve (and primecount) to disable ARM SVE for GCC < 14. I will implement that fix in the `multiarch_arm_sve.cmake` CMake script using the workaround below:
```C++
// GCC < 14 inlines the ARM SVE functions into
// the non-SVE caller, which then crashes on
// CPUs without ARM SVE.
#if defined(__GNUC__) && \
!defined(__clang__) && \
__GNUC__ < 14
Error: ARM SVE multiarch requires GCC >= 14!
#endif
```
in my case the bug was on a VM running Linux, with host running macOS on an M4 arm64 CPU.
|
|
I have now committed the fix from my previous post: 989e5b2. In my tests using an AWS Graviton2 CPU with Ubuntu 24.04 and GCC 12 and 13, this fixes the bug (no illegal instruction crash anymore). This fix disables ARM SVE runtime dispatching for GCC < 14, hence using those compilers the ARM NEON kernels will be used instead. The ARM NEON kernels are virtually as fast as the ARM SVE kernels, so I don't expect any slowdown because of this fix. @dimpase Can you please confirm that my bug fix also fixes your issue? |
|
On Tue, Nov 10, 2026 at 10:18:57AM -0800, Kim Walisch wrote:
kimwalisch left a comment (kimwalisch/primesieve#201)
I have now committed the fix from my previous post: 989e5b2. In my tests using an AWS Graviton2 CPU with Ubuntu 24.04 and GCC 12 and 13, this fixes the bug (no illegal instruction crash anymore).
This fix disables ARM SVE runtime dispatching for GCC < 14, hence using those compilers the ARM NEON kernels will be used instead. The ARM NEON kernels are virtually as fast as the ARM SVE kernels, so I don't expect any slowdown because of this fix.
@dimpase Can you please confirm that my bug fix also fixes your issue?
I'll be able to check in a day or two, currently have to access to the
right box.
|
|
@kimwalisch Confirmed: 989e5b2 fixes our issue, without the patch proposed in this PR. I built its exact parent (v12.17) and the fix in fresh directories on the same non-SVE Linux ARM64 VM, using Ubuntu 24.04.5 / GCC 13.3.0 and matching The fix passed all 34 CTests, Both primesieve source trees were unmodified upstream commits, and installed packages were left unchanged. This confirms the fix for our GCC 13 / non-SVE ARM64 setup. Thanks for the fix! |
|
Thanks for the feedback. I will do a new bug fix release of both primesieve and primecount in the next days. In primecount-9.0 there was another issue with a unit test that fails on i586 that I only discovered after the release. The new release will fix this issue as well. |
Built with gcc-13 primesieve 12.17 Linux ARM bottle crashes on a CPU without SVE, e.g.
would crash. A register/disassembly capture shows
executing in the baseline PreSieve::preSieve path even though its SVE runtime flag is false.
More details in dimpase/homebrew-tap#111