Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ Currently, Stockfish has the following UCI options:
Example: `C:\tablebases\wdl345;C:\tablebases\wdl6;D:\tablebases\dtz345;D:\tablebases\dtz6`

It is recommended to store .rtbw files on an SSD. There is no loss in storing
the .rtbz files on a regular HD.
the .rtbz files on a regular HD. It is recommended to verify all md5 checksums of the
downloaded tablebase files (`md5sum -c checksum.md5`) as corruption will lead to
engine crashes.

* #### SyzygyProbeDepth
Minimum remaining search depth for which a position is probed. Set this option
Expand Down
10 changes: 10 additions & 0 deletions src/syzygy/tbprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ class TBFile : public std::ifstream {
return *baseAddress = nullptr, nullptr;

fstat(fd, &statbuf);
if (statbuf.st_size % 64 != 16)
{
std::cerr << "Corrupt tablebase file " << fname << std::endl;
exit(1);
}
*mapping = statbuf.st_size;
*baseAddress = mmap(nullptr, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
madvise(*baseAddress, statbuf.st_size, MADV_RANDOM);
Expand All @@ -233,6 +238,11 @@ class TBFile : public std::ifstream {

DWORD size_high;
DWORD size_low = GetFileSize(fd, &size_high);
if (size_low % 64 != 16)
{
std::cerr << "Corrupt tablebase file " << fname << std::endl;
exit(1);
}
HANDLE mmap = CreateFileMapping(fd, nullptr, PAGE_READONLY, size_high, size_low, nullptr);
CloseHandle(fd);

Expand Down