Commit Graph

18250 Commits

Author SHA1 Message Date
Michael Tautschnig 8286e02a45
Merge pull request #4412 from owen-jones-diffblue/fix-type-consistency-in-dereference-expressions
Fix type consistency in dereference expressions
2019-03-21 07:24:42 +00:00
martin 2bee6b195f There is no need for argc and argv to be new, as long types match
Consider the following unlikely sequence of events:

$ cat ~/tmp/can-delete/main.c
int main (int argc, char **argv) {
  return 0;
}
$ goto-cc main.c -o main.goto
$ cbmc main.goto --function main
CBMC version 5.11 (cbmc-5.11-881-gd52cd0d1e-dirty) 64-bit x86_64 linux
Reading GOTO program from file
Reading: /home/martin/tmp/can-delete/main.goto
failed to insert argc symbol
SUPPORT FUNCTION GENERATION ERROR

argc and argv both exist and it is fine to re-use them.  If the
addition fails it will throw an exception, the .second bool is only
false in the case they already exist which is likely harmless.
2019-03-20 18:31:40 +00:00
Owen a82c02a1cb Infer correct type in checked_dereference
Now that we have a single-argument constructor for dereference_exprt
there isn't any need to pass the type in to checked_dereference. It
is a potential source of bugs that we might use the followed type and
therefore use a struct type instead of a struct tag-type, which will
cause type consistency problems elsewhere.
2019-03-20 17:20:18 +00:00
Owen 2979362ea4 Validate dereference expressions
Check that the type of the operand is a pointer type and the type of the
dereference expression is precisely the subtype. This should catch any
mistakes where we have followed a struct-tag type to get a struct type,
which will mess up our strict requirements for type equality.
2019-03-20 17:20:18 +00:00
Owen 2d0405fd77 Fix wrong type for dereference expression #2
We should keep the struct tag type, not follow it and get the struct type
2019-03-20 17:13:29 +00:00
Owen a72469af60 Fix wrong type for dereference expression #1
We should keep the struct tag type, not follow it and get the struct type
2019-03-20 17:13:29 +00:00
svorenova 1c309e1b23
Merge pull request #4410 from peterschrammel/break-down-checker-operator
Break down steps of goto checker operator
2019-03-20 11:14:07 +00:00
Chris Smowton ed7a3bae9f
Merge pull request #4407 from smowton/smowton/feature/dead-always-uses-generation-zero
Symex code_deadt: always use L2 generation zero
2019-03-20 09:54:39 +00:00
Peter Schrammel 279e8f81c6 Break down steps of single-path symex checker
Enables better code reuse in derived classes.
2019-03-20 09:35:56 +00:00
Romain Brenguier 294bab6093
Merge pull request #4394 from romainbrenguier/refactor/symex-rename-type-2
Make rename return a renamedt<exprt, level>
2019-03-20 09:09:55 +00:00
Romain Brenguier fa227a0e51 Make goto_instruction take a renamedt argument
This reflects the assumptions on the argument better.
2019-03-20 07:36:04 +00:00
Romain Brenguier 57c960f30e Make symex_output take renamedt args
This reflect the assumptions we should have on the arguments.
2019-03-20 07:36:04 +00:00
Romain Brenguier bd87e57d7c Make function call take renamedt arguments
This reflects the assumption this makes on the expressions passed as
arguments.
2019-03-20 07:36:04 +00:00
Romain Brenguier 7134344484 Add a simplify function for renamedt
This assumes the simplification does not break the renaming.
2019-03-20 07:36:03 +00:00
Romain Brenguier 114e721e47 Make rename return a renamedt<exprt, level>
This is to reflect in the type that an expression as been renamed and we
can then make some functions only accept expressions of that type.
2019-03-20 07:35:59 +00:00
Owen 77075e680b Test temp var for this argument in virtual function calls
A temporary variable should be created for the `this` argument of a
virtual function call when there is a dispatch table and the `this`
argument involves a dereference.
2019-03-20 06:07:48 +00:00
Owen 3e1d0d0dc7 Copy directly preceding ASSUMEs
Copy directly preceding ASSUMEs, changing the argument for `this` to
the new temporary variable for `this`. This is mainly aimed at null
checks, to make the local safe pointer analysis work. We stop as
soon as we find an instruction that is not an ASSERT or ASSUME.
2019-03-20 06:07:45 +00:00
Owen d7cfc9dbf7 Use correct function identifier in symbol name 2019-03-20 06:05:54 +00:00
Peter Schrammel ed90b37b09 Break down steps of single-path symex-only checker
Enables better code reuse in derived classes.
2019-03-20 00:08:40 +00:00
Peter Schrammel 0e3a8d07c2 Make getters const 2019-03-19 23:57:06 +00:00
Peter Schrammel 426529ce0f Break down steps of multi-path symex goto checker
Enables better code reuse in derived classes.
2019-03-19 23:57:06 +00:00
Peter Schrammel 9f56d4ec96 Break down steps of multi-path symex-only goto checker
Enables better code reuse in derived classes.
2019-03-19 22:51:23 +00:00
Chris Smowton 320ef61b70
Merge pull request #4408 from smowton/smowton/fix/multianewarray-line-numbers
multianewarray instruction: don't require a source line number
2019-03-19 21:13:22 +00:00
Chris Smowton d201bad22d Always use L2 generation 0 for dead variables
This means that merge_goto's special merge logic for generation zero works on both dead local variables
and on #return_value global variables defined for the second and subsequent times, discounting the
control-flow where the variable is dead.
2019-03-19 18:20:20 +00:00
Chris Smowton 233700390b StringToLowerCase: Reduce string length limit
The string solver was consuming a very large amount of memory with the limit set to 10000;
this appears to be pure chance whether the solver picks a solution requiring universals to be
instantiated a large number of times. The other tests in this directory are already set to
limit string length to 1000, so I just do the same thing here.
2019-03-19 18:20:20 +00:00
Chris Smowton 589116df67
Merge pull request #4343 from smowton/smowton/feature/explicily-initialise-externs
Fix symex of functions that may throw
2019-03-19 18:18:48 +00:00
Peter Schrammel 92a94019fd
Merge pull request #4400 from peterschrammel/satcheck-messaget
Satcheck doesn't inherit from messaget anymore
2019-03-19 17:57:44 +00:00
Chris Smowton 35f0b2e952 multianewarray instruction: don't require a source line number
Removing this doesn't appear to have any bad consequence, and line numbers cannot generally be relied upon,
since compiling with -g:none or stripping all debug info means they won't be available.

Add a variant of the multianewarray test to check this works, and expand it slightly with comment-out parts
that presumably at some point did not work, but do now.
2019-03-19 17:17:18 +00:00
Daniel Poetzl 6533631183
Merge pull request #3983 from danpoe/feature/gdb-api
GDB API [blocks: #4261]
2019-03-19 17:04:26 +00:00
Petr Bauch d803bde3c9 Fix based on comments 2019-03-19 16:01:40 +00:00
Daniel Poetzl fa2ed7b3a8 Install gdb on macos builds 2019-03-19 15:52:32 +00:00
Daniel Poetzl fcbe7b933b Add new unit tests for the gdb api
This adds new unit tests for gdb_apit. The tests compile a test file test.c and
then run gdb on it (via gdb_apit).
2019-03-19 15:52:32 +00:00
Daniel Poetzl aece5a5644 Enable and update gdb api unit tests
This enables the gdb api unit tests (in memory-analyzer/gdb_api.cpp) and adapts
them to include use_catch.h instead of catch.hpp.
2019-03-19 15:52:32 +00:00
Daniel Poetzl 7e6bd17018 Replace #ifdef __linux__ by guards allowing more Unices
We require the Unix fork() system call (in unistd.h)
2019-03-19 15:52:32 +00:00
Daniel Poetzl 0e1a5ca35d Add file module_dependencies.txt to memory-analyzer 2019-03-19 15:52:31 +00:00
Daniel Poetzl b72245b45d Install gdb package in CI to make gdb_apit unit tests work 2019-03-19 15:52:31 +00:00
Owen 0589328df0 Only create temp var for this arg if needed
If the this argument doesn't contain a dereference then value-set
filtering will work on it even without creating a temporary
variable
2019-03-19 15:01:56 +00:00
Owen c6ea853f8c Use temp variable for `this` in dispatch tables
This is so that value-set filtering in symex will
filter elements which don't have the correct class
identifier out of the value-set for `this`.
2019-03-19 15:01:56 +00:00
Owen a4d3881d27 Make symbol_table parameter non-const
We will add a symbol to it, so it cannot be const.
2019-03-19 15:01:56 +00:00
Chris Smowton d341910754 Add test for constant- and value-set propagation out of a may-throw function
This is possible now that #return_value variables are not subject to special rules
in phi_function, and the value-set is cleared when variables are marked dead, meaning
that there is no chance a second function call which only sometimes defines #return_value
might witness the previous call's results.
2019-03-19 14:58:32 +00:00
Chris Smowton c12ff79b3a Symex phi function: merge global variables like any other
Now that the front-ends are required to explicitly assign a nondet value where that
is intended (e.g. an undefined extern global), rather than leaving an undefined value,
there is no need to special-case merging them.
2019-03-19 14:57:51 +00:00
Chris Smowton 3d46af3693 Erase dead values from the value-set
This saves memory while achieving very similar behaviour as a read from a value removed from
the value-set still yields a failed object. The difference is what happens on a merge:
a merge with an explicit failed object retains it, while a merge against an empty value-set
will discard the undefined possibility. This is fine for dead variables, where on a control-
flow convergance we may safely assume we came from the path where it is not dead, but for
declarations and undefined extern variables the front-end and goto-symex must collaborate to
ensure an explicit nondet value is present.
2019-03-19 14:57:59 +00:00
Chris Smowton 46ba4e74f8 C front-end: explicitly initialise nondet variables
This enables us to distinguish the case where the front-end intended a nondet
initialiser from an undefined variable, such as a "#return_value" global before
a call or on paths which throw an exception.
2019-03-19 14:57:51 +00:00
Chris Smowton 17fa596768
Merge pull request #4386 from smowton/smowton/feature/symex-condition-driving
Symex: propagate assumptions and conditions
2019-03-19 14:55:28 +00:00
Nathan Phillips 391738d670
Merge pull request #4405 from NathanJPhillips/feature/skip-instrs-not-atts
Update Java bytecode parser to always load code attributes
2019-03-19 14:20:29 +00:00
Daniel Poetzl 5c518e70ac Add empty lines in gdb_api.cpp to improve readability 2019-03-19 13:42:01 +00:00
Daniel Poetzl 58f6d116d9 Remove unused gdb_inaccessible_memory_exceptiont 2019-03-19 13:42:01 +00:00
Daniel Poetzl fa3c78f9fb Switch gdb_apit to using the gdb machine interface
This changes gdb_apit to use the gdb machine interface (mi) instead of the gdb
command line user interface to communicate with gdb.
2019-03-19 13:42:01 +00:00
Daniel Poetzl 0b9480bb40 Update banners for gdb api files 2019-03-19 13:42:01 +00:00
Daniel Poetzl a49c4214c4 Add #endif comments to gdb api header file 2019-03-19 13:42:01 +00:00