fastchess-tests fails on Raspberry Pi 5 only with gcc
fastchess-tests was compiled with make -j4 tests without errors.
This error occurs when fastchess-tests are run afterwards:
terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to open file: app/tests/data/das.pgn
===============================================================================
tests/pgn_reader_test.cpp:150:
TEST SUITE: PGN Reader
TEST CASE: Read PGN file with invalid file
tests/pgn_reader_test.cpp:150: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal
===============================================================================
[doctest] test cases: 71 | 70 passed | 1 failed | 26 skipped
[doctest] assertions: 454 | 454 passed | 0 failed |
[doctest] Status: FAILURE!
Aborted (core dumped)
This is the output of the error under valgrind:
==4058== Conditional jump or move depends on uninitialised value(s)
==4058== at 0x4C15D44: ??? (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C17697: _Unwind_RaiseException (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x496A8FB: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x17384B: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058==
==4058== Conditional jump or move depends on uninitialised value(s)
==4058== at 0x401A8A4: _dl_find_object (dl-find_object.c:372)
==4058== by 0x4C19F43: _Unwind_Find_FDE (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C15D67: ??? (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C17697: _Unwind_RaiseException (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x496A8FB: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x17384B: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058==
==4058== Conditional jump or move depends on uninitialised value(s)
==4058== at 0x401A8B4: _dl_find_object (dl-find_object.c:379)
==4058== by 0x4C19F43: _Unwind_Find_FDE (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C15D67: ??? (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C17697: _Unwind_RaiseException (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x496A8FB: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x17384B: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058==
==4058== Conditional jump or move depends on uninitialised value(s)
==4058== at 0x401AA28: _dl_find_object (dl-find_object.c:380)
==4058== by 0x4C19F43: _Unwind_Find_FDE (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C15D67: ??? (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C17697: _Unwind_RaiseException (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x496A8FB: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x17384B: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058==
==4058== Use of uninitialised value of size 8
==4058== at 0x4C16120: ??? (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C17697: _Unwind_RaiseException (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x496A8FB: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x17384B: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058==
==4058== Invalid read of size 4
==4058== at 0x4C16120: ??? (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x4C17697: _Unwind_RaiseException (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==4058== by 0x496A8FB: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x17384B: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== Address 0x58004f0c is in the Text segment of /usr/libexec/valgrind/memcheck-arm64-linux
==4058== at 0x58004F0C: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058==
terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to open file: app/tests/data/das.pgn
===============================================================================
tests/pgn_reader_test.cpp:150:
TEST SUITE: PGN Reader
TEST CASE: Read PGN file with invalid file
tests/pgn_reader_test.cpp:150: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal
===============================================================================
[doctest] test cases: 71 | 70 passed | 1 failed | 26 skipped
[doctest] assertions: 454 | 454 passed | 0 failed |
[doctest] Status: FAILURE!
==4058==
==4058== Process terminating with default action of signal 6 (SIGABRT)
==4058== at 0x4CC6898: __pthread_kill_implementation (pthread_kill.c:44)
==4058== by 0x4C7683B: raise (raise.c:26)
==4058== by 0x4C61A7F: abort (abort.c:79)
==4058== by 0x496D4D7: __gnu_cxx::__verbose_terminate_handler() (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x496A56F: ??? (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x4960E03: std::terminate() (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x496A907: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==4058== by 0x17384B: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058== by 0x58004F0B: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
==4058==
==4058== HEAP SUMMARY:
==4058== in use at exit: 185,697 bytes in 182 blocks
==4058== total heap usage: 128,535 allocs, 128,353 frees, 23,252,715 bytes allocated
==4058==
==4058== LEAK SUMMARY:
==4058== definitely lost: 0 bytes in 0 blocks
==4058== indirectly lost: 0 bytes in 0 blocks
==4058== possibly lost: 464 bytes in 2 blocks
==4058== still reachable: 185,233 bytes in 180 blocks
==4058== of which reachable via heuristic:
==4058== stdstring : 68 bytes in 1 blocks
==4058== suppressed: 0 bytes in 0 blocks
==4058== Rerun with --leak-check=full to see details of leaked memory
==4058==
==4058== Use --track-origins=yes to see where uninitialised values come from
==4058== For lists of detected and suppressed errors, rerun with: -s
==4058== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)
Aborted (core dumped)
System: Raspberry Pi 5 Ubuntu Server 24.10 aarch64 gcc 14.2.0-4ubuntu2
I can reproduce on pi5...
==389172== Conditional jump or move depends on uninitialised value(s)
==389172== at 0x4C15D44: ??? (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==389172== by 0x4C17697: _Unwind_RaiseException (in /usr/lib/aarch64-linux-gnu/libgcc_s.so.1)
==389172== by 0x496A8FB: __cxa_throw (in /usr/lib/aarch64-linux-gnu/libstdc++.so.6.0.33)
==389172== by 0x16FE4F: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:78)
==389172== by 0xFFFFFFFFFFFFFFFF: ???
==389172== Uninitialised value was created by a stack allocation
==389172== at 0x16F730: fastchess::book::PgnReader::PgnReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) (pgn_reader.cpp:73)
==389172==
terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to open file: app/tests/data/das.pgn
currently I have no clue what goes wrong.. but it looks like a miscompile? idk
It also does not occur when compiled with clang 19.1.1
[doctest] test cases: 97 | 97 passed | 0 failed | 0 skipped
[doctest] assertions: 579 | 579 passed | 0 failed |
[doctest] Status: SUCCESS!
yeah just tested the same :D
@Torom I assume this also causes a segmentation fault for you? It does for me at least
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
class StreamParser {
public:
StreamParser(std::istream &stream) : stream_buffer(stream) {}
void readGames() { stream_buffer.fill(); }
private:
class StreamBuffer {
private:
static constexpr std::size_t N = 1024;
public:
StreamBuffer(std::istream &stream) : stream_(stream) {}
bool fill() {
if (!stream_.good()) return false;
stream_.read(buffer_, N * N);
auto bytes_read = stream_.gcount();
return bytes_read > 0;
}
private:
std::istream &stream_;
char buffer_[N * N];
};
StreamBuffer stream_buffer;
};
class Reader {
public:
explicit Reader(const std::string &p, int l) : l_(l) {
std::ifstream file(p);
if (!file.is_open()) {
throw 42;
}
StreamParser parser(file);
parser.readGames();
}
private:
int l_;
};
int main() {
auto reader = Reader("file", 1);
return 0;
}
compiled like this
g++-14 -O0 -std=c++17 -Wall -Wextra -Wpedantic -Wuninitialized -fno-strict-aliasing -fwrapv -g3 test.cpp && ./a.out
$ g++-14 -O0 -std=c++17 -Wall -Wextra -Wpedantic -Wuninitialized -fno-strict-aliasing -fwrapv -g3 test.cpp && ./a.out
test.cpp: In function ‘int main()’:
test.cpp:55:10: warning: variable ‘reader’ set but not used [-Wunused-but-set-variable]
55 | auto reader = Reader("file", 1);
| ^~~~~~
Segmentation fault (core dumped)
Mh seems like an upstream bug somewhere gcc/ubuntu.. for now i'd say use clang, does fishtest run the fastchess compilation correctly with clang if you specify it?
~I haven't tested it~, but it looks like it does: https://github.com/official-stockfish/fishtest/blob/0087ae4d885a54d7efcb4aa4710273fb261f8d9a/worker/worker.py#L495-L500
Edit: I just tested it, when you start fishtest with --compiler clang++ it works.
Good, then at least people who run into this fallback to clang
thanks for your input, it also got it to work like this. sudo install clang and sudo apt install llvm clang lld after that it run with --compiler clang++
~I haven't tested it~, but it looks like it does: https://github.com/official-stockfish/fishtest/blob/0087ae4d885a54d7efcb4aa4710273fb261f8d9a/worker/worker.py#L495-L500
Edit: I just tested it, when you start fishtest with
--compiler clang++it works.
@Torom
~if you have an ubuntu account please also say that this bug affects you, there should be a button or dropdown somewhere when you are logged in https://bugs.launchpad.net/ubuntu/+source/gcc-14/+bug/2095206~
so was a gcc bug and should be fixed in updated gcc versions see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119610... not quite sure how to easily update from 14.2.0 to 14.2.1, maybe your package manager updated their version