Skip to content

cbmc --verbosity 10 --xml-ui invariant failure #7038

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

Closed
markrtuttle opened this issue Jul 27, 2022 · 4 comments
Closed

cbmc --verbosity 10 --xml-ui invariant failure #7038

markrtuttle opened this issue Jul 27, 2022 · 4 comments
Assignees
Labels
aws Bugs or features of importance to AWS CBMC users aws-medium

Comments

@markrtuttle
Copy link
Collaborator

CBMC version: 5.61.0
Operating system: MacOS 11.6.7

Create the file main.c

#include<assert.h>

int main() {
  int x;
  assert(x);
}

and run the command

cbmc --verbosity 10 --xml-ui main.c

and cbmc fails with

--- begin invariant violation report ---
Invariant check failed
File: /tmp/cbmc-20220707-65576-1rz4dy2/src/util/xml.cpp:113 function: escape
Condition: ch >= ' '
Reason: XML does not support escaping non-printable character 226
Backtrace:
...
--- end invariant violation report ---
Abort trap: 6

I think the problem is that --verbosity 10 generates lines like

ASSERT ¬(main::1::x!0@1#1 = 0)

and the character ¬ is extended ASCII character 170 (I can't explain the 226 in the error message). In xml.cpp, line 113 asserts the data invariant ch > ' ' but since ch=170 interpreted as a signed character is negative, the assertion fails and the invariant failure is thrown. I think the check ch > ' ' is intended to skip the unprintable characters below the space character in ASCII, but I think the extended ASCII characters above 128 are mostly printable characters and should be okay.

@jimgrundy jimgrundy added aws Bugs or features of importance to AWS CBMC users aws-medium labels Aug 10, 2022
@jimgrundy
Copy link
Collaborator

This is a real pain that has bitten a few of us recently. It's really hard to debug for the user as it gives you no hint as to where and in what file you need to find the offending character.

@thomasspriggs
Copy link
Contributor

The 128-255 range does potentially open up a can of character encoding worms. But they certainly correspond to printable characters for (code page dependant) extended ascii or part of a multi-byte sequence for many printable UTF-8 characters. In this case I think it is the ⇔ character which is encoded as 0xE2 0x87 0x94 or 226 135 148 in decimal. This is from the line __CPROVER_malloc_is_new_array#1 ⇔ false in the output.

I agree with Mark's assessment. The check should probably be (unsigned char)ch >= 32. @tautschnig Any comment from you on this, given that git-blame says you added this condition?

@thomasspriggs
Copy link
Contributor

PR #7109 which should address this issue has now been merged. @markrtuttle Can you confirm whether you are satisfied with the current solution so we can close out this issue?

@tautschnig tautschnig removed their assignment Sep 10, 2022
@tautschnig
Copy link
Collaborator

I agree with Mark's assessment. The check should probably be (unsigned char)ch >= 32. @tautschnig Any comment from you on this, given that git-blame says you added this condition?

Thanks you @thomasspriggs for fixing the bug that I had introduced! I had just failed to take into account signedness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users aws-medium
Projects
None yet
Development

No branches or pull requests

4 participants