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
Implement simple string methods #95
Conversation
Here's an example that produces the wrong result. It appears to work find with ASCII. Do we have to hold off on implementing this until we can get full unicode support in import z3
from crosshair.libimpl.builtinslib import SmtStr
from crosshair.statespace import SimpleStateSpace, StateSpaceContext
import crosshair.core_and_libs
space = SimpleStateSpace()
with StateSpaceContext(space):
s = SmtStr(z3.StringVal('Â'))
print(s.join(['a', 'b', 'c']), 'Â'.join(['a', 'b', 'c'])) Output a\u{ffffffc2}b\u{ffffffc2}c aÂbÂc |
My experience is that at least our version of z3 has issues with unicode, and have been working under the idea that (for the moment) SmtStr is only for ASCII. (well, technically a little larger - the codepoints 0-255) You may have noticed that I'm using sequences of bitvectors in places to try and keep z3 from attempting to use other values. In spite of this restriction, I think we should always consider it a bug if Crosshair produces a counterexample that doesn't reproduce. |
A heads-up (and apology). I'm trying to make the naming less confusing: 8f87df3 performs a large rename of |
No problem, I think it's a great idea! |
Based on a very brief excursion into the land of z3 and unicode, the issue appears whenever we try to materialize a string value (for instance, by printing it). I think for now not something I want to spend an inordinate amount of time on. I'll continue on with the string methods and ping you when done. |
@pschanely any idea why CrossHair can find the counterexample on 3.8 but not on 3.7? |
OK - apologies for the delays here!
|
Ah, silly me,
|
Thanks for the help! I don't think it's a good idea to add a flaky test and then rely on the timeout for it to pass (because that can still be ruined by poor computation speed), so I've taken it out for now. Maybe in some next PR we'll do some performance benchmarking, eh? I think I'd like to call this ready for merging. Let me know if I need to do anything else about it. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing. This is a lot of stuff! A few minor comments.
Sounds good on the testing. Later this week, I'd like to forward you a potential new test pattern for how we might expand our coverage, reduce flakes, and improve test time. I'd be curious about your opinions on it!
Thanks for the review. Definitely up for having a look at the test pattern. :) |
This PR continues work on #39