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

Add support to stack unwind panic strategy #692

Open
celinval opened this issue Dec 11, 2021 · 1 comment
Open

Add support to stack unwind panic strategy #692

celinval opened this issue Dec 11, 2021 · 1 comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature. [E] Unsupported Construct Add support to an unsupported construct

Comments

@celinval
Copy link
Contributor

Requested feature: We would like to be able to verify the logic that is triggered while unwinding a panic statement.
Use case: Programs sometimes rely on the unwind logic to ensure that there is not resource leak or persistent data inconsistency. Thus, it is important to users to be able to verify that the program will correctly handle its resource if a panic occurs.
Link to relevant documentation (Rust reference, Nomicon, RFC): N/A
Is this a breaking change?

Test case:

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// We currently do not support stack unwinding panic strategy. Once we do, this testcase should
// fail during the verification with both the panic and the assertion failing.
// To run manually, execute:
// ```
// RUSTFLAGS="--C panic=unwind --crate-type lib" rmc unwind_fixme.rs  --function create
// ```
//
// compile-flags: --C panic=unwind --crate-type lib
// rmc-flags: --function create
// rmc-verify-fail

pub struct DummyResource {
    pub data: Option<String>,
}

impl Drop for DummyResource {
    fn drop(&mut self) {
        assert!(self.data.is_some(), "This should fail");
    }
}

#[no_mangle]
pub fn create(empty: bool) -> DummyResource {
    let mut dummy = DummyResource { data: None };
    if empty {
        unimplemented!("This is not supported yet");
    }
    dummy.data = Some(String::from("data"));
    dummy
}

With stack unwinding, the assertion inside the DummyResource::drop() should fail. However, with the abort strategy, the same assertion should hold.

@celinval celinval added [C] Feature / Enhancement A new feature request or enhancement to an existing feature. and removed Cat: enhancement labels Nov 9, 2022
@tedinski tedinski added the [E] Unsupported Construct Add support to an unsupported construct label Nov 14, 2022
@tedinski
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Feature / Enhancement A new feature request or enhancement to an existing feature. [E] Unsupported Construct Add support to an unsupported construct
Projects
None yet
Development

No branches or pull requests

2 participants