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

Failures when iterating over results #556

Closed
adpaco-aws opened this issue Oct 15, 2021 · 3 comments
Closed

Failures when iterating over results #556

adpaco-aws opened this issue Oct 15, 2021 · 3 comments
Labels
[C] Bug This is a bug. Something isn't working.

Comments

@adpaco-aws
Copy link
Contributor

adpaco-aws commented Oct 15, 2021

The "Rust by Example" book contains several examples where iterators are used over result values. Take for instance this code (actual example in that section):

// compile-flags: --edition 2018
// rmc-flags: --cbmc-args --unwind 4 --object-bits 9
#![allow(unused)]
pub fn main() {
    let strings = vec!["tofu", "93", "18"];
    let numbers: Vec<_> = strings
        .into_iter()
        .filter_map(|s| s.parse::<i32>().ok())
        .collect();
    println!("Results: {:?}", numbers);
}

This example does not successfully verify with RMC. Running this command

rmc src/test/dashboard/books/Rust\ by\ Example/Error\ handling/Iterating\ over\ Results/22.rs --cbmc-args --unwind 4 --object-bits 9 | grep FAIL

gets me these results:

[std::ptr::const_ptr::<impl *const T>::offset_from.pointer_primitives.12] line 391 pointer outside object bounds in POINTER_OBJECT(var_11): FAILURE
[std::ptr::const_ptr::<impl *const T>::offset_from.pointer_primitives.16] line 391 pointer outside object bounds in POINTER_OBJECT(var_12): FAILURE
[std::result::Result::<T, E>::ok.assertion.1] line 647 unreachable code: FAILURE
VERIFICATION FAILED

But the example runs fine in Rust, producing this output:

Results: [93, 18]
@zhassan-aws
Copy link
Contributor

Kani still reports two spurious failures on this example"

Check 46: _ZN4core3num60_$LT$impl$u20$core..str..traits..FromStr$u20$for$u20$i32$GT$8from_str17h7557cdc4c649c89fE.assertion.1
	 - Status: FAILURE
	 - Description: "assertion false"


Check 64: std::result::Result::<T, E>::ok.assertion.1
	 - Status: FAILURE
	 - Description: "unreachable code"

@celinval
Copy link
Contributor

I think this is a duplicate from #576. These are issues related to the fact that we are not able to link against std functions.

celinval added a commit that referenced this issue Mar 22, 2022
@zhassan-aws zhassan-aws assigned jaisnan and unassigned zhassan-aws Apr 19, 2022
tedinski pushed a commit to tedinski/rmc that referenced this issue Apr 22, 2022
tedinski pushed a commit to tedinski/rmc that referenced this issue Apr 25, 2022
tedinski pushed a commit to tedinski/rmc that referenced this issue Apr 26, 2022
tedinski pushed a commit that referenced this issue Apr 27, 2022
@celinval
Copy link
Contributor

This issue has been resolved by #1785. The issue is covered by the test added in the same PR. https://github.com/model-checking/kani/blob/main/tests/kani/Strings/parse.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Bug This is a bug. Something isn't working.
Projects
None yet
Development

No branches or pull requests

4 participants