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

read_aiger: Fix incorrect read of binary Aiger without outputs #4359

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

georgerennie
Copy link
Collaborator

This was unconditionally reading the rest of a line when parsing outputs, but if none exist that means an extra line is parsed. This causes the following bad state parsing to fail with the error "Line %u cannot be interpreted as a bad state property!" on a file with only bad state properties and no outputs

Fix does the same as the similar check in Line 738 to only finish reading the line if any outputs have been read.

@@ -722,7 +722,8 @@ void AigerReader::parse_aiger_binary()
module->connect(wire, createWireIfNotExists(module, l1));
outputs.push_back(wire);
}
std::getline(f, line); // Ignore up to start of next line
if (O > 0)
std::getline(f, line); // Ignore up to start of next line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please move up the getline below f >> l1 so we consume the full line per every output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sure I can do that, will do the same for the following if (B > 0) and the ascii parser while im at it

@georgerennie georgerennie force-pushed the aiger_parse_bug branch 2 times, most recently from 8e20c64 to 69e6caa Compare April 29, 2024 11:56
@@ -0,0 +1,8 @@
aag 3 2 0 0 1 1 0 0 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a malformed aiger file? What do the tests do with it then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah in hindsight i did not give that file a very good name. its just an aiger file that has a bad state node instead of an output node (so would have caused the issue that this pr fixes). it is a valid aiger file though. will rename

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah please do other than that the PR looks good

* Also makes all ascii parsing finish reading lines and adds a small
  test
@povik povik merged commit 640d6a5 into YosysHQ:main Apr 29, 2024
18 checks passed
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

Successfully merging this pull request may close these issues.

2 participants