Commit Graph

17849 Commits

Author SHA1 Message Date
Thomas Spriggs d903114133 Refactor `java_record_outputs`
The comment calling `java_record_outputs` was uncertain about what it
was doing. The implementation of `java_record_outputs` is now split into
3 functions in order to make it clearer exactly what things are marked
as outputs. The type signature has been updated to return a
`code_blockt` in order to avoid returning the results by output
parameter.
2019-02-26 14:51:59 +00:00
Thomas Spriggs 419343d82d Remove unused result variable from `java_record_outputs`
Removed because it is unneeded and easier to read the rest of the code
without this red herring.
2019-02-26 14:51:59 +00:00
Michael Tautschnig 13b5e2b7b3
Merge pull request #3481 from thk123/refactor/remove-symex-magic-string
Don't use symex_dynamic:: magic string in multiple places
2019-02-26 14:14:21 +00:00
Daniel Kroening ca12c1c957 use goto_programt::make_X
This avoids incomplete construction.
2019-02-26 13:56:53 +00:00
Daniel Kroening e9b01f65f3 avoid access to instructiont::code
This will allow protecting instructiont::code.
2019-02-26 13:56:53 +00:00
Daniel Kroening 8912a6dc14 use make_assignment(lhs, rhs)
This is slightly shorter.
2019-02-26 13:56:53 +00:00
Daniel Kroening 85ba2253fe prefer .add over .emplace
This is easier to read.
2019-02-26 13:56:53 +00:00
Daniel Kroening 17dde90c47 use instructiont::turn_into_skip
This is a clearer idiom.
2019-02-26 13:56:53 +00:00
Michael Tautschnig af7124fc83
Merge pull request #4278 from tautschnig/enable-concurrency-tests
Enable cbmc-concurrency regression tests by default
2019-02-26 12:24:13 +00:00
Michael Tautschnig 78437a1873 Also disable pthread tests on OSX
They all fail with "pointer handling for concurrency is unsound."
2019-02-26 11:36:26 +00:00
Michael Tautschnig fc69353d91 Fix goto-program conversion of fence instructions
Using it->code.set(ID_statement, ...) no longer suffices as it will not set
code.id(), which is ID_nil after initialisation. Thus any such instruction is
removed during goto-program cleanup.

Use the recently added APIs instead, which will ensure proper initialisation.
2019-02-26 11:36:26 +00:00
Michael Tautschnig 0f2f082552 Enable cbmc-concurrency regression tests by default
For some reason we had not included these in our standard set of regression
tests, and sure enough they got out of sync and one actual regression happened.
2019-02-26 11:36:26 +00:00
Michael Tautschnig cdab2671a2 Update location numbers after adding instructions
remove_returnst::do_function_calls may introduce new instructions. Doing so
requires a call to compute_location_numbers to ensure instruction numbers are
assigned. To avoid recomputing location numbers across all goto functions, the
facility from goto_functionst is used, which will ensure globally unique
location numbers (though they might not be globally contiguous).
2019-02-26 11:27:53 +00:00
Michael Tautschnig 2694ac5fe8 Revert "bugfix: must do .update() after remove_returns"
This reverts commit abbb389422.

In #2089 a broad cleanup of redundant calls to .update() was done. Let's stay in
this spirit and call .update() when necessary, and not "just to be safe."
2019-02-26 11:27:53 +00:00
Fotis Koutoulakis 5ab4e4aa5d
Merge pull request #4277 from NlightNFotis/fix-goto-harness-pointer-init
Fix: Do not nondet functions and fix scoping issue
2019-02-26 10:57:27 +00:00
thk123 042ad74770 Don't use symex_dynamic:: magic string in multiple places 2019-02-26 10:29:47 +00:00
Elizabeth Polgreen 507766ed45 Docker file to compile Xen
To create docker file, run "make" in integration/xen.  The Docker file will
build CBMC, download Xen upstream version, and one-line-scan, and then attempt
to build Xen using goto-cc.
2019-02-26 01:51:59 +00:00
Michael Tautschnig b8678a403c
Merge pull request #4271 from tautschnig/pthread_cond_wait
pthread_cond_wait may return spuriously
2019-02-25 18:50:36 +00:00
Michael Tautschnig e50449df9d
Merge pull request #4279 from romainbrenguier/bugfix/bdd_as_expr
Bugfix in bdd::as_expr
2019-02-25 18:21:07 +00:00
Michael Tautschnig 4c6a9fcd30 pthread_cond_wait may return spuriously
The man page states: "In general, whenever a condition wait returns, the thread
has to re-evaluate the predicate associated with the condition wait to determine
whether it can safely proceed, should wait again, or should declare a timeout. A
return from the wait does not imply that the associated predicate is either true
or false."

The regression test is based on
pthread-divine/condvar_spurious_wakeup_false-unreach-call.c from SV-COMP.
2019-02-25 17:49:37 +00:00
Michael Tautschnig b994da4cf2 pthread tests should not be run on Windows
These will never work on Windows, which doesn't have POSIX threads.
2019-02-25 17:49:16 +00:00
Michael Tautschnig 98f33a7165
Merge pull request #2033 from tautschnig/lcnf-cleanup
Use propt::lcnf instead of propt::l_set_to{true,false}
2019-02-25 17:31:42 +00:00
Romain Brenguier e1fb6b7fec Add unit test for BDD
This adds a test case to check there are no mistakes in the BDD to expr
conversions.
This test can fail without the previous fix.
2019-02-25 17:28:16 +00:00
Fotis Koutoulakis cefb1ddb89 Fix: Do not nondet functions and fix scoping issue
In goto-harness:
- we used is_static && is_lvalue to determine something was global.
  Turns out that this also applies to extern functions for some reason,
  so we ended up accidentally creating nondet assignments to those.
  We now check type.id() != ID_code as well.
- we declared pointers to local variables. In if blocks. Which went
  out of scope before using them. This meant we had a bunch of
  dangling references. We solve this by creating global variables
  for our pointer-pointees instead of local ones.

Co-authored-by: Fotis Koutoulakis <fotis.koutoulakis@diffblue.com>
Co-authored-by: Hannes Steffenhagen <hannes.steffenhagen@diffblue.com>
2019-02-25 17:13:25 +00:00
Romain Brenguier 6406fdfc0a Fix bdd.as_expr()
There was a mistake in the way complement is computed when going to the
then_branch.
2019-02-25 16:16:55 +00:00
Michael Tautschnig bbb1ce8d95
Merge pull request #4270 from tautschnig/alloca-free
Detect use of free() with alloca-allocated objects
2019-02-25 12:14:01 +00:00
Michael Tautschnig 8e1cf18824
Merge pull request #4259 from smowton/smowton/admin/benchmark-script-improvements
Benchmark script improvements
2019-02-25 11:06:01 +00:00
Michael Tautschnig f9edf73454
Merge pull request #4273 from tautschnig/remove-replace_all
Remove replace_all string utility
2019-02-25 10:58:15 +00:00
Michael Tautschnig 3c3348a98e Detect use of free() with alloca-allocated objects
As we internally use dynamic allocation, we previously did not distinguish
alloca-allocated from malloc/calloc-allocated ones.
2019-02-25 10:57:35 +00:00
Michael Tautschnig 8c5303a2dd Use propt::l_set_to_{true,false}
Avoids the lower-level l_set_to(..., {true,false}) and may then
highlight opportunities for further optimisation.
2019-02-25 10:50:21 +00:00
Michael Tautschnig 6589d99d22
Merge pull request #4257 from romainbrenguier/feature/add-const
Define an add_const utility function
2019-02-25 10:12:31 +00:00
Michael Tautschnig 3a577d784c Add a definition of alloca
Benchmarks not including headers files fail as we only provided a definition of
__builtin_alloca, which alloca expands to in standard libary headers, but none
for alloca directly.
2019-02-25 09:30:46 +00:00
Chris Smowton 587b701a17 Benchmark script: improve file naming, readme consistency
The example arguments file is named with _example suffix like the existing example method list,
and the branch and develop CSV files are so named and listed in (x, y) order everywhere.
2019-02-25 09:16:58 +00:00
Michael Tautschnig 1a970e3e91
Merge pull request #4274 from tautschnig/value-set_ranged_for
Use ranged-for to iterate over value_sett:valuest
2019-02-25 08:30:17 +00:00
Romain Brenguier 32af11e41d Use as_const where relevent in rename
In some places the non const version of .type() and others would be
called.
We force the const version to be called by using as_const.

In the example in
 `jbmc/regression/jbmc-strings/StringConcat/test_buffer_nondet_loop5`
 this reduced the number of calls to detach from 744638 to 736844.
2019-02-25 07:00:10 +00:00
Romain Brenguier d07fbfba92 Define an as_const utility function
This is useful in particular when we want to force the const version of
a method to be called.
For exprt there can be differences in performance between const and
non-const.
2019-02-25 07:00:08 +00:00
Michael Tautschnig 24f1625ba7 clang-format compatible indent of preprocessor commands
Update required as the preceding commit touches nearby lines.
2019-02-25 00:53:35 +00:00
Michael Tautschnig 8583395bd3 Use ranged-for to iterate over value_sett:valuest
This is easier to read and simplifies switching between representations.
2019-02-25 00:53:12 +00:00
Michael Tautschnig 01d1ebe9dc Remove replace_all string utility
There are several reasons why we should not maintain this here:
* We do not have a single use in the code base.
* It's completely unrelated to program analysis or any other CBMC matter.
* If anyone else uses it, they are more than welcome to copy the implementation.
* It was based on MIT-licensed code copyrighted by an external author. Mixing
  licenses within individual files is questionable practice.
2019-02-25 00:44:58 +00:00
Michael Tautschnig 5c8839fc8c
Merge pull request #3478 from diffblue/replace_all_doc
add replace_all documentation
2019-02-25 00:43:52 +00:00
Michael Tautschnig b02b2fd718
Merge pull request #4265 from diffblue/trace-return-bug
function identifier in trace is wrong when function has no body
2019-02-24 11:06:06 +00:00
Michael Tautschnig 8a49a13e2a
Merge pull request #4263 from diffblue/use_transform
use instructiont::transform
2019-02-24 11:04:08 +00:00
Daniel Kroening 458b0df632 bug: functions without body generate incorrect trace
We see a return from main, but wanted to see a return from
function_without_body.
2019-02-23 19:12:04 +00:00
Daniel Kroening 30a8a70f9d clang-format trace_show_function_calls/main.c 2019-02-23 19:10:53 +00:00
Daniel Kroening da678b1be9 use instructiont::transform
This avoids direct access to data in instructiont.
2019-02-23 16:02:03 +00:00
Michael Tautschnig 744c6f3aec
Merge pull request #4256 from tautschnig/allocated-bounds
Take __CPROVER_allocated_memory regions into account for --bounds-check
2019-02-22 18:32:08 +00:00
Chris Smowton 4c724de487 Java frontend: ignore CProver methods earlier
We already tried to ignore org.cprover.CProver methods such as nondetInt, relying upon
the front-end to supply stub bodies if desired based on their type. However, by creating
symbols for them as for normal (non-stub) methods, but then refusing to provide a body or
advertise them as normal methods, we failed to set up their type properly (specifically
the parameter names), as they were neither set like a stub (upon symbol creation, upon
discovery by a caller) or like a normal method (during java_bytecode_convert_method). By
refusing to create the symbol at all, this treats the special CProver methods more like
normal stubs: their symbols are now created on demand.

It is also no longer necessary for java_bytecode_languaget::methods_provided to special
case them, as they are not added to method_bytecodet either, again matching "real" stub
methods more closely.
2019-02-22 17:59:54 +00:00
Michael Tautschnig df79716ccc
Merge pull request #4252 from tautschnig/use-parameter-identifiers
Use goto_functiont::parameter_identifiers instead of looking at the type [blocks: #4167]
2019-02-22 17:58:48 +00:00
Michael Tautschnig 5b32a6125d
Merge pull request #4245 from tautschnig/prefix.h-include
Do not use has_prefix in source_location.h
2019-02-22 17:24:48 +00:00
Michael Tautschnig 51f57965ba Take __CPROVER_allocated_memory regions into account for --bounds-check
We already took these into account for --pointer-check. Do the same for
--bounds-check.
2019-02-22 16:57:28 +00:00