Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit 55df0ee causes runtime crash when compiled with MinGW-w64 on Windows 10. #5108

Open
jackL999 opened this issue Mar 12, 2024 · 14 comments
Labels
build needs-analysis Needs further analysis

Comments

@jackL999
Copy link

Describe the issue

Using MinGW-w64 from winlibs.com (gcc 13.2) Stockfish crashes with a runtime fault. All previous Stockfish versions from commit 632f1c2 and before compile and run without any problems.
I successfully compiled and executed commit 55df0ee in Linux and Android (arm64-v8a and armeabi-v7a) without any issues. Only the Windows 10 version fails to execute after compilation.

Expected behavior

To run in Windows 10 without crashing.

Steps to reproduce

stockfish.exe bench 2048 2 13 default depth nnue

Anything else?

No response

Operating system

Windows

Stockfish version

Stockfish development commit 55df0ee (12/03/2024)

@Disservin
Copy link
Member

Can you give us some information about how you compiled it and what the compilation output and stockfish output was?

@jackL999
Copy link
Author

I compiled it as I always do using the command,
make -j8 profile-bulid ARCH=x86-64-bmi2 COMP=mingw CPPFLAGS="-DNNUE_EMBEDDDING_OFF -march=haswell"
this compilation will fail as soon as it tries to execute Stockfish during profiling.

After experimenting on this I discovered that the problem only occurs when "-march=haswell" is included in CPPFLAGS.
Note the source compiles with out any errors using
make -j8 bulid ARCH=x86-64-bmi2 COMP=mingw CPPFLAGS="-DNNUE_EMBEDDDING_OFF -march=haswell"
it just won't run without crashing.

Something in the latest source is clobbering or interfering with the optimization setting "-march=haswell".

@Disservin
Copy link
Member

Disservin commented Mar 12, 2024

Can you run this through gdb perhaps (if it is installed for you)?
gdb .\stockfish.exe
run

@jackL999
Copy link
Author

Upon examining the changes to src/nnue/network.cpp and src/uci.cpp I noticed a lot of changes to Embedding nnue. I wonder if those are the source of bug. Could it be the source isn't parsing the CPPFLAGS instruction properly?

@Disservin
Copy link
Member

@jackL999 can you please give the entire output of what is shown on the terminal?

@Disservin
Copy link
Member

Disservin commented Mar 12, 2024

You also have a typo in profile-bulid it's profile-build and in -DNNUE_EMBEDDDING_OFF... it's -DNNUE_EMBEDDING_OFF

@jackL999
Copy link
Author

Yes, but those typos were only made here. They don't exist in the command line executed in the terminal window. That command is taken directly from the history file and has successfully executed the compilation of Stockfish source scores of times.

@Disservin
Copy link
Member

@jackL999 can you please give the entire output of what is shown on the terminal?

…?

@jackL999
Copy link
Author

from previous request, running gdb, I get
(gdb) r
Starting program: c:\v\Stockfish\src\stockfish.exe
[New Thread 33284.0x9214]
[New Thread 33284.0x91b0]
[New Thread 33284.0x9118]
Stockfish dev-20240312-55df0ee0 by the Stockfish developers (see AUTHORS file)

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff622e3561a in Stockfish::UCI::UCI(int, char**) ()
(gdb)

@jackL999
Copy link
Author

Compilation produces the following,
make -j8 build ARCH=x86-64-bmi2 COMP=mingw CPPFLAGS="-DNNUE_EMBEDDING_OFF -march=haswell"
Default net: nn-1ceb1ade0001.nnue
nn-1ceb1ade0001.nnue available : OK
Network validated
Default net: nn-baff1ede1f90.nnue
nn-baff1ede1f90.nnue available : OK
Network validated

Config:
debug: 'no'
sanitize: 'none'
optimize: 'yes'
arch: 'x86_64'
bits: '64'
kernel: 'MSYS_NT-10.0-19045'
os: 'Windows_NT'
prefetch: 'yes'
popcnt: 'yes'
pext: 'yes'
sse: 'yes'
mmx: 'no'
sse2: 'yes'
ssse3: 'yes'
sse41: 'yes'
avx2: 'yes'
avxvnni: 'no'
avx512: 'no'
vnni256: 'no'
vnni512: 'no'
neon: 'no'
dotprod: 'no'
arm_version: '0'
target_windows: 'yes'

Flags:
CXX: x86_64-w64-mingw32-c++
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one
LDFLAGS: -static -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -save-temps

Testing config sanity. If this fails, try 'make help' ...

make ARCH=x86-64-bmi2 COMP=mingw all
make[1]: Entering directory 'c:/v/Stockfish/src'
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o benchmark.o benchmark.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o bitboard.o bitboard.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o evaluate.o evaluate.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o main.o main.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o misc.o misc.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o movegen.o movegen.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o movepick.o movepick.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o position.o position.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o search.o search.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o thread.o thread.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o timeman.o timeman.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o tt.o tt.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o uci.o uci.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o ucioption.o ucioption.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o tune.o tune.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o tbprobe.o syzygy/tbprobe.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o nnue_misc.o nnue/nnue_misc.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o half_ka_v2_hm.o nnue/features/half_ka_v2_hm.cpp
x86_64-w64-mingw32-c++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -DNNUE_EMBEDDING_OFF -march=haswell -c -o network.o nnue/network.cpp
x86_64-w64-mingw32-c++ -o stockfish.exe benchmark.o bitboard.o evaluate.o main.o misc.o movegen.o movepick.o position.o search.o thread.o timeman.o tt.o uci.o ucioption.o tune.o tbprobe.o nnue_misc.o half_ka_v2_hm.o network.o -static -Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -DNDEBUG -O3 -funroll-loops -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -mbmi -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -DGIT_SHA=55df0ee0 -DGIT_DATE=20240312 -DARCH=x86-64-bmi2 -flto -flto-partition=one -save-temps
make[1]: Leaving directory 'c:/v/Stockfish/src'

@jackL999
Copy link
Author

jackL999 commented Mar 12, 2024

I re-ran gdb with stockfish compiled using debug=yes
make -j8 build ARCH=x86-64-bmi2 debug=yes COMP=mingw CPPFLAGS="-DNNUE_EMBEDDING_OFF -march=haswell"
Default net: nn-1ceb1ade0001.nnue
nn-1ceb1ade0001.nnue available : OK
Network validated
Default net: nn-baff1ede1f90.nnue
nn-baff1ede1f90.nnue available : OK
Network validated

Config:
debug: 'yes'
[....]
make[1]: Leaving directory 'c:/v/Stockfish/src'

It produced the following output
gdb.exe stockfish.exe
[...]
Reading symbols from stockfish.exe...
(gdb) r
Starting program: c:\v\Stockfish\src\stockfish.exe
[New Thread 41048.0x85f8]
[New Thread 41048.0x9970]
[New Thread 41048.0xa334]
Stockfish dev-20240312-55df0ee0 by the Stockfish developers (see AUTHORS file)

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff7a1746d20 in Stockfish::UCI::UCI (this=this@entry=0x5ffc20, argc=argc@entry=1, argv=argv@entry=0x791ba0)
at uci.cpp:96
96 threads.set({options, threads, tt, networks});
(gdb)

@jackL999
Copy link
Author

FYI, I was able to successfully compile and execute commit f072634, but commit 1a26d69 "Refactor Network Usage" causes the same Segmentation fault as noted with the latest commit.
It appears the problem began with changes made in commit 1a26d69.

@jackL999
Copy link
Author

jackL999 commented Mar 13, 2024

I was able to get the latest commit 55df0ee to compile and execute on Windows without problems using MinGW64 on ARCH Linux.

Running the command "stockfish.exe compiler" in Windows using the ARCH Linux build produces the following output,

Stockfish dev-20240312-55df0ee0 by the Stockfish developers (see AUTHORS file)
Compiled by : g++ (GNUC) 13.1.0 on MinGW64
Compilation architecture : x86-64-bmi2
Compilation settings : 64bit BMI2 AVX2 SSE41 SSSE3 SSE2 POPCNT
Compiler VERSION macro : 13.1.0

This means that the problem is likely with the winlibs.com MinGW64 compiler and not with the Stockfish source. It is odd though that every build using this compiler on source commits prior to 1a26d69 worked without any issues.

@Disservin
Copy link
Member

@jackL999 btw the new comple uses 13.1 vs your original one was 13.2 ...
did you also try running a make clean before compiliation?

Regarding winlibs, I recommend following the installation guide for windows from here https://github.com/official-stockfish/Stockfish/wiki/Developers#windows

@Disservin Disservin added needs-analysis Needs further analysis and removed bug labels Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build needs-analysis Needs further analysis
Projects
None yet
Development

No branches or pull requests

3 participants
@Disservin @jackL999 and others