Skip to content
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

Backporting 2.5.1 #821

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## unreleased

## v2.5.1

### Bug fixes
* fix a critical soundness bug with bvnot primitive (#819)

## v2.5.0

### New features
Expand Down
16 changes: 7 additions & 9 deletions src/lib/reasoners/bitv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,13 @@ module Shostak(X : ALIEN) = struct
let other ~neg t sz ctx =
let r, ctx' = X.make t in
let ctx = List.rev_append ctx' ctx in
match X.extract r with
| Some bv ->
if neg then
try negate_abstract bv, ctx with
| Failure _ ->
[ { bv = Other (X.term_embed (E.BV.bvnot t)); sz } ], ctx
else
bv, ctx
| None -> [ { bv = Other r; sz } ], ctx
let bv = embed r in
if neg then
try negate_abstract bv, ctx with
| Failure _ ->
[ { bv = Other (X.term_embed (E.BV.bvnot t)); sz } ], ctx
else
bv, ctx

let extract_st i j ({ bv; sz } as st) =
match bv with
Expand Down
2 changes: 2 additions & 0 deletions tests/bitv/testfile-bvnot-term.dolmen.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

unknown
7 changes: 7 additions & 0 deletions tests/bitv/testfile-bvnot-term.dolmen.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(set-logic BV)

(declare-const x (_ BitVec 4))
(declare-const y (_ BitVec 4))
(assert (= x (bvnot y)))
(assert (distinct y x))
(check-sat)
22 changes: 22 additions & 0 deletions tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -117948,6 +117948,28 @@
(diff
testfile-bvnot.dolmen.expected
testfile-bvnot.dolmen_dolmen.output)))
(rule
(target testfile-bvnot-term.dolmen_dolmen.output)
(deps (:input testfile-bvnot-term.dolmen.smt2))
(package alt-ergo)
(action
(chdir %{workspace_root}
(with-stdout-to %{target}
(ignore-stderr
(with-accepted-exit-codes 0
(run %{bin:alt-ergo}
--timelimit=2
--enable-assertions
--output=smtlib2
--frontend dolmen
%{input})))))))
(rule
(alias runtest-quick)
(package alt-ergo)
(action
(diff
testfile-bvnot-term.dolmen.expected
testfile-bvnot-term.dolmen_dolmen.output)))
(rule
(target testfile-bitv023_ci_cdcl_no_minimal_bj.output)
(deps (:input testfile-bitv023.ae))
Expand Down