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

BUG: Handling end-of-file encountered in parsing numerical data in game files #457

Open
bcollin3 opened this issue Jun 7, 2024 · 1 comment
Labels
bug c++ Items which involve writing in C++ good-first-issue Items which are (relatively) straightforward, and good ways to get into the code
Milestone

Comments

@bcollin3
Copy link

bcollin3 commented Jun 7, 2024

If you call Game.parse_game() on a string that ends in a decimal utility value then the program will crash after a minute or two after consuming all of the system's ram.
For example:

import pygambit as gbt
s='NFG 1 R "prisoners dilemma"\n {"Player 1" "Player 2"} {2 2}\n -6 -6 -10 0 0 -10 -1 -1.0'
gbt.Game.parse_game(s)

will cause a crash but

import pygambit as gbt
s='NFG 1 R "prisoners dilemma"\n {"Player 1" "Player 2"} {2 2}\n -6 -6 -10 0 0 -10 -1 -1.0\n'
gbt.Game.parse_game(s)

will not.

@tturocy
Copy link
Member

tturocy commented Jun 11, 2024

In GameParserState::GetNextToken() checks for the validity of the file after an attempted .get() are not done consistently, in particular in some places in which numerical data are parsed. This results in an infinite loop.

@tturocy tturocy changed the title Game.parse_game() Memory leak Issue BUG: Handling end-of-file encountered in parsing numerical data in game files Jun 11, 2024
@tturocy tturocy added this to the gambit-16.3.0 milestone Jun 11, 2024
@tturocy tturocy added good-first-issue Items which are (relatively) straightforward, and good ways to get into the code c++ Items which involve writing in C++ bug labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c++ Items which involve writing in C++ good-first-issue Items which are (relatively) straightforward, and good ways to get into the code
Projects
None yet
Development

No branches or pull requests

2 participants