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

Fix casting warnings in Projection::new #277

Closed
avanhatt opened this issue Jun 30, 2021 · 5 comments · Fixed by #1205
Closed

Fix casting warnings in Projection::new #277

avanhatt opened this issue Jun 30, 2021 · 5 comments · Fixed by #1205
Assignees
Labels
[C] Bug This is a bug. Something isn't working. [F] Soundness Kani failed to detect an issue T-High Priority Tag issues that have high priority T-MLP Should Have

Comments

@avanhatt
Copy link
Contributor

There is a commented-out assertion with a TODO in Projection::new: the assertion fails on some regression tests; but also on some standard library issues that would be useful to have an actual check for. Once we fix the regressions we should enable it.

        // TODO: these assertions fail on a few regressions. Figure out why.
        // I think it may have to do with boxed fat pointers.
        // assert!(
        //     Self::check_expr_typ(&goto_expr, &mir_typ_or_variant, ctx),
        //     "\n{:?}\n{:?}",
        //     &goto_expr,
        //     &mir_typ_or_variant
        // );
@avanhatt avanhatt added the [C] Bug This is a bug. Something isn't working. label Jun 30, 2021
@avanhatt
Copy link
Contributor Author

Example: boxed closures, like this:

   // Create a boxed once-callable closure
    let f: Box<dyn FnOnce()> = Box::new(|| {});
    f();

@avanhatt avanhatt self-assigned this Jun 30, 2021
@avanhatt avanhatt added this to To do in Sprint 2021-08-03 via automation Jul 21, 2021
@avanhatt avanhatt removed this from To do in Sprint 2021-08-03 Aug 3, 2021
@avanhatt avanhatt added this to To do in Sprint 2021-08-17 via automation Aug 3, 2021
@adpaco-aws adpaco-aws added the T-High Priority Tag issues that have high priority label Oct 26, 2021
@avanhatt avanhatt removed their assignment Dec 8, 2021
@celinval celinval self-assigned this Mar 11, 2022
@celinval celinval added this to To do in Sprint 2022-03-29 Mar 11, 2022
@celinval
Copy link
Contributor

We need to investigate these. Currently, kani print warnings like the one above for these issues:

WARN kani_compiler::codegen_cprover_gotoc::codegen::place Unexpected type mismatch in projection:
Expr { value: Member { lhs: Expr { value: Symbol { identifier: "_ZN4core3num7flt2dec17digits_to_dec_str17h455a99ccc8826c4bE::1::var_4::parts" }, typ: StructTag("tag-_15158566036879639663"), location: None }, field: "data" }, typ: Pointer { typ: UnionTag("tag-_7532365074337032130") }, location: None }
Expr type
Pointer { typ: UnionTag("tag-_7532365074337032130") }
Type from MIR
FlexibleArray { typ: UnionTag("tag-_7532365074337032130") }

@tautschnig
Copy link
Member

Not that I have a solution here as to why "Pointer" and "FlexibleArray" seem to be confused here, but I just wanted to note that CBMC now takes a #flexible_array_member annotation on flexible array members.

@celinval celinval moved this from To do to In progress in Sprint 2022-03-29 Mar 15, 2022
@celinval celinval changed the title Enable type check assertion in Projection::new Fix casting warnings in Projection::new Mar 15, 2022
@celinval
Copy link
Contributor

From what I gather so far, it looks like we are incorrectly using Struct { Pointer } when adding the symbol to the symbol table. Trying to pin down where this is happening.

@celinval
Copy link
Contributor

Oh, I think I found it. :)

Type::datatype_component("data", element_type.to_pointer()),

It looks like we are assuming in a lot of places in this file that a slice is encoded as:

struct<T> Slice{
   data: const* T,
   len: usize,
}

But in the following line we expect a FlexibleArray:

ty::Slice(e) => self.codegen_ty(*e).flexible_array_of(),

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. [F] Soundness Kani failed to detect an issue T-High Priority Tag issues that have high priority T-MLP Should Have
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

5 participants