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

std::exit while pgns are being processed may lead to crashes #55

Open
robertnurnberg opened this issue Oct 1, 2023 · 3 comments
Open

Comments

@robertnurnberg
Copy link
Contributor

On linux I get segmentation faults when --fixFEN finds missing keys in the metadata, say. In itself this is not a problem, as the code should exit anyway. But a more graceful way to stop would be nice. I think the segmentation faults comes from the parallel execution of many PGN analysises, and maybe the exit(1) leads to some unexpected states there. (Sadly, I do not know how to fix this.)

Sample output for me:

Missing "book_depth" key in metadata for .epd book for test pgns/23-09-23/650f26ffadc82c88993ddd80/650f26ffadc82c88993ddd80
pt pt 00
scoreWDLstat: external/chess.hpp:1872: virtual void chess::Board::placePiece(chess::Piece, chess::Square): Assertion `board_[sq] == Piece::NONE' failed.
file_from -1
Segmentation fault      (core dumped)
@Disservin
Copy link
Member

mhh the assertion is weird, do you really only get the crash when you pass --fixFen ?

@robertnurnberg
Copy link
Contributor Author

Agreed, any exit while files are being processed would cause the same behaviour.

@robertnurnberg robertnurnberg changed the title --fixFEN errors may lead to crashes std::exit while pgns are being processed may lead to crashes Oct 1, 2023
@mhouppin
Copy link
Contributor

It might be because the std::exit() in Analysis::header() causes the destruction of objects with static storage duration, and pos_map gets destroyed before the other worker threads get cleaned up ? So you'd get invalid accesses to the global variable and thus segmentation faults when you have missing position keys.

Assuming this is what causes the crash, I'd see two solutions to this: either skip the offending game completely (while still emitting a warning because one of the FENs couldn't be found in the book), or signal the error to the main thread in some way, which then aborts all the workers and exits with an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants