forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove expression from cbmc check descriptions (rust-lang#906)
* Remove expression from cbmc check descriptions We have no control over the expression printed. These checks usually end up printing some temporary variables which are rather confusing. For now, we replace the message to remove the expressions and make it more user friendly.
- Loading branch information
Showing
14 changed files
with
278 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Description: "assertion failed: 1 + 1 == 2" | ||
Description: "dead object in OBJECT_SIZE(&temp_0)" | ||
Description: "pointer to dead object" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
// Check we don't print temporary variables as part of CBMC messages. | ||
extern crate kani; | ||
|
||
use kani::any; | ||
|
||
// Use the result so rustc doesn't optimize them away. | ||
fn dummy(result: f32) -> f32 { | ||
result.round() | ||
} | ||
|
||
#[kani::proof] | ||
fn main() { | ||
dummy(any::<f32>() + any::<f32>()); | ||
dummy(any::<f32>() - any::<f32>()); | ||
dummy(any::<f32>() * any::<f32>()); | ||
dummy(any::<f32>() / any::<f32>()); // This is not emitting CBMC check. | ||
dummy(any::<f32>() % any::<f32>()); // This is not emitting CBMC check. | ||
dummy(-any::<f32>()); // This is not emitting CBMC check. | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Failed Checks: NaN on addition | ||
Failed Checks: arithmetic overflow on floating-point addition | ||
Failed Checks: NaN on subtraction | ||
Failed Checks: arithmetic overflow on floating-point subtraction | ||
Failed Checks: NaN on multiplication | ||
Failed Checks: arithmetic overflow on floating-point multiplication | ||
Failed Checks: NaN on division | ||
Failed Checks: arithmetic overflow on floating-point division | ||
Failed Checks: division by zero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
// Check we don't print temporary variables as part of CBMC messages. | ||
|
||
fn not_zero(p1: *const i32) { | ||
assert!(unsafe { *p1 != 0 }); | ||
} | ||
|
||
#[kani::proof] | ||
fn main() { | ||
let mut ptr = 10 as *const i32; | ||
if kani::any() { | ||
let var1 = 0; | ||
ptr = &var1 as *const i32; | ||
} | ||
not_zero(ptr); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Failed Checks: dereference failure: pointer NULL | ||
Failed Checks: dereference failure: deallocated dynamic object | ||
Failed Checks: dereference failure: dead object | ||
Failed Checks: dereference failure: pointer outside object bounds | ||
Failed Checks: dereference failure: invalid integer address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
// Check we don't print temporary variables as part of CBMC messages. | ||
// cbmc-flags: --signed-overflow-check | ||
extern crate kani; | ||
|
||
use kani::any; | ||
|
||
// Ensure rustc encodes the operation. | ||
fn dummy(var: i32) { | ||
kani::assume(var != 0); | ||
} | ||
|
||
|
||
#[kani::proof] | ||
fn main() { | ||
dummy(any::<i32>() + any::<i32>()); | ||
dummy(any::<i32>() - any::<i32>()); | ||
dummy(any::<i32>() * any::<i32>()); | ||
dummy(any::<i32>() / any::<i32>()); // This is not emitting CBMC check. | ||
dummy(any::<i32>() % any::<i32>()); // This is not emitting CBMC check. | ||
dummy(any::<i32>() << any::<i32>()); | ||
dummy(any::<i32>() >> any::<i32>()); | ||
dummy(-any::<i32>()); // This is not emitting CBMC check. | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Failed Checks: arithmetic overflow on signed addition | ||
Failed Checks: arithmetic overflow on signed subtraction | ||
Failed Checks: arithmetic overflow on signed multiplication | ||
Failed Checks: division by zero | ||
Failed Checks: arithmetic overflow on signed division | ||
Failed Checks: division by zero | ||
Failed Checks: result of signed mod is not representable | ||
Failed Checks: shift distance is negative | ||
Failed Checks: shift distance too large | ||
Failed Checks: shift operand is negative | ||
Failed Checks: arithmetic overflow on signed shl | ||
Failed Checks: shift distance is negative | ||
Failed Checks: shift distance too large | ||
Failed Checks: arithmetic overflow on signed unary minus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
// Check we don't print temporary variables as part of CBMC messages. | ||
// cbmc-flags: --unsigned-overflow-check | ||
extern crate kani; | ||
|
||
use kani::any; | ||
|
||
// Ensure rustc encodes the operation. | ||
fn dummy(var: u32) { | ||
kani::assume(var != 0); | ||
} | ||
|
||
#[kani::proof] | ||
fn main() { | ||
dummy(any::<u32>() + any::<u32>()); | ||
dummy(any::<u32>() - any::<u32>()); | ||
dummy(any::<u32>() * any::<u32>()); | ||
dummy(any::<u32>() / any::<u32>()); | ||
dummy(any::<u32>() % any::<u32>()); | ||
dummy(any::<u32>() << any::<u32>()); | ||
dummy(any::<u32>() >> any::<u32>()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Failed Checks: arithmetic overflow on unsigned addition | ||
Failed Checks: arithmetic overflow on unsigned subtraction | ||
Failed Checks: arithmetic overflow on unsigned multiplication | ||
Failed Checks: division by zero | ||
Failed Checks: division by zero | ||
Failed Checks: shift distance too large | ||
Failed Checks: shift distance too large |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Check 1: main.assertion.1 | ||
Description: "assertion failed: 1 + 1 == 3" | ||
Description: "dead object in OBJECT_SIZE(&temp_0)" | ||
Failed Checks: assertion failed: 1 + 1 == 3 | ||
Description: "pointer to dead object" | ||
Failed Checks: assertion failed: 1 + 1 == 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
Check 1: main.assertion.1 | ||
Description: "assertion failed: 1 + 1 == 2" | ||
Description: "dead object in OBJECT_SIZE(&temp_0)" | ||
Description: "pointer to dead object" |