fix syzygy crash on Apple Silicon by unrolling tbprobe adjustment loop

A bit tricky to identify, but in `apple-silicon` builds, specifying a value for
`SyzygyPath` could still lead to crashes at certain depths from a
SIGBUS/SIGSEGV.

This PR replaces the `std::count_if()` adjustment in `tbprobe.cpp`'s
`do_probe_table()` with an annotated handwritten loop, avoiding the clang/LTO
miscompilation behind the crash.

closes https://github.com/official-stockfish/Stockfish/pull/6721

No functional change.
This commit is contained in:
Ryan Lefkowitz
2026-04-15 19:05:14 +02:00
committed by Joost VandeVondele
parent b63bd7b78e
commit bb5f0100b0
2 changed files with 5 additions and 2 deletions
+1
View File
@@ -223,6 +223,7 @@ Ron Britvich (Britvich)
rqs rqs
Rui Coelho (ruicoelhopedro) Rui Coelho (ruicoelhopedro)
rustam-cpp rustam-cpp
Ryan Lefkowitz (rlefko)
Ryan Hirsch Ryan Hirsch
Ryan Schmitt Ryan Schmitt
Ryan Takker Ryan Takker
+4 -2
View File
@@ -949,8 +949,10 @@ encode_remaining:
// groups (similar to what was done earlier for leading group pieces). // groups (similar to what was done earlier for leading group pieces).
for (int i = 0; i < d->groupLen[next]; ++i) for (int i = 0; i < d->groupLen[next]; ++i)
{ {
auto f = [&](Square s) { return groupSq[i] > s; }; int adjust = 0;
auto adjust = std::count_if(squares, groupSq, f); DISABLE_CLANG_LOOP_VEC
for (Square* sq = squares; sq != groupSq; ++sq)
adjust += groupSq[i] > *sq;
n += Binomial[i + 1][groupSq[i] - adjust - 8 * remainingPawns]; n += Binomial[i + 1][groupSq[i] - adjust - 8 * remainingPawns];
} }