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

crucible_fresh_var produces wrong cryptol type for nested struct types #583

Closed
brianhuffman opened this issue Nov 11, 2019 · 1 comment · Fixed by #584 or #589
Closed

crucible_fresh_var produces wrong cryptol type for nested struct types #583

brianhuffman opened this issue Nov 11, 2019 · 1 comment · Fixed by #584 or #589

Comments

@brianhuffman
Copy link
Contributor

The example is that I'm trying to verify a C function that uses the following struct types:

typedef struct {
    uint32_t fst;
    uint32_t snd;
} pair_t;

typedef struct {
    uint32_t head;
    pair_t tail;
} triple_t;

In LLVM, the type triple_t unfolds to the nested struct type { i32, { i32, i32 } }, which should correspond to the Cryptol nested tuple type ([32], ([32], [32])).

However, when I use crucible_fresh_var "x" (llvm_struct "struct.triple_t"), it gives me a term with cryptol type ([32], [32], [32]). Then crucible_points_to complains that the types are not memory compatible, because { i32, i32, i32 } does not match { i32, { i32, i32 } }.

The confusion might arise because the Cryptol types (a, (b, c)) and (a, b, c) have the same representation in saw-core, and we're probably reconstructing the cryptol type by type inference on the saw-core term. Instead, we should compute the cryptol type directly from the llvm type, so that we don't lose information.

@atomb
Copy link
Contributor

atomb commented Nov 13, 2019

Integration test test0048_alloc_post fails as a result of this. There are a variety of fixes we could consider, but I think that making nested struct types memory compatible with non-nested types may be the right things (as well as making one-element structs memory-compatible with the type of their one element).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants