Comments (4)
OK, handling ptrtoint as well, while we're at it.
from smack.
The way i2p and p2i are implemented right now, SMACK reports a false bug for this example:
int main(void){
int x = (int)malloc(sizeof(int));
long y = (int)x;
int z = (int)y;
_x = 5;
__SMACK_assert(_z == 5);
}
I wonder if i2p and p2i should be just noops? Any good reason not to have them as noops?
from smack.
I'm not really sure about this one. If we treat i2p and p2i as no-ops, then any arithmetic on integers derived from the pointers becomes weird, since arithmetic uses only the "offset" component. I'm not really sure where this problem might manifest in practice, but consider the following program:
int _p = malloc(..);
*p = 0;
int x = (int) p;
int y = x + 1;
int z = y - 1;
int *q = (int *) z;
// here p and q alias, since x == z
*q = 5;
assert (_p == 0);
// this assertion does not hold.
Our translation, treating i2p and p2i as no-ops would work as follows:
p := $ptr(R,0);
x := $ptr(R,0);
y := $ptr(NULL,1);
z := $ptr(NULL,0);
q := $ptr(NULL,0);
// here p and q do not alias...
$Mem[q] := 5;
assert ($Mem[p] == 0);
// this assertion holds
The way our translation works now flags this as an error.
p := $ptr(R,0);
x := $ptr(NULL,0);
y := $ptr(NULL,1);
z := $ptr(NULL,0);
q := $ptr(S,0);
// here p and q MAY alias, given that R and S can be equal
$Mem[q] := 5;
assert ($Mem[p] == 0);
// this assertion may not hold
M
from smack.
I agree with your point. What we are doing now is sound, which is great and is probably good enough for most of real-world examples. Handling i2p/p2i precisely without having a good need for that does not make sense at this point. So let's just issue a warning that it is not handled precisely and that's it.
from smack.
Related Issues (20)
- Feature request: Attempt to compute loop bounds. Unroll to bound if possible. Error if not. HOT 1
- Heads up: renaming master branch into main HOT 1
- Implement a per-allocation-site memory-safety checking
- Running example with SMACK
- Multi-language model checking, on inequality modify languages to match correct model?
- Verifying Fortran Intrinsic Function ABS
- Handling thread_local variables HOT 9
- Some Rust `Box` operation is internally supported by rustc HOT 1
- Leverage `instcombine` pass
- Generalize `clang-options` into `compiler-options` HOT 1
- Upgrade Rust version to support edition 2021
- Verifying D programs
- Debug information when using LLVM IR as an input HOT 2
- How it can support ensures, requires, invariant API in Rust
- llvm2bpl report error when use smack generate boogie code
- Build issue on Ubuntu 18.04
- Unhandled LLVM intrinsic generated from math.c HOT 1
- Unhandled experimental intrinsics crash SMACK
- All programs verify when SMT solver (Z3) is not present HOT 1
- Advanced SMACK guide
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smack.