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/LLVM: Return type checking is too lax #443

Open
langston-barrett opened this issue May 17, 2019 · 4 comments
Open

Crucible/LLVM: Return type checking is too lax #443

langston-barrett opened this issue May 17, 2019 · 4 comments
Labels
needs test Issues for which we should add a regression test subsystem: crucible-llvm Issues related to LLVM bitcode verification with crucible-llvm topics: error-handling Issues involving the way SAW responds to an error condition type: bug Issues reporting bugs or unexpected/unwanted behavior
Milestone

Comments

@langston-barrett
Copy link
Contributor

langston-barrett commented May 17, 2019

I'm having buyer's remorse for the strict return type checking for CrucibleSetup blocks. With the strict check introduced there, I get messages like

Incompatible types for return value when verifying engine_table_select
Expected: %struct.engine_st*
but given value of type: void*

(see this minimal example: test.tar.gz). However, with the old check (checkRegisterCompatibility), differences between types like i30 and i32 weren't detected (see #438).

It seems to me like the best solution would be to stop using typeOfSetupValue, and instead develop a predicate

compatibleTypes :: SetupValue -> Crucible.MemType -> Maybe Err

But perhaps there's a better way I'm not aware of? Am I missing something important about the semantics of e.g. MemType vs StorageType?

@robdockins
Copy link
Contributor

It's an unfortunate misnaming, but MemTypes correspond to things that can be stored in an LLVM virtual register, while StorageTypes correspond to things that can be stored in memory. Registers are not byte-oriented, and can contain arbitrary bit-widths, entire structs, etc. Memory is byte-oriented, and can only store things that are multiples of 8-bits... moreover StorageType ignores altogether the distinction between pointers and bitvectors and the distinction between arrays and vectors.

Fundamentally, what I think you're asking here is: "what is the right check for argument/return value compatibility?" I think it's clear that MemType equality is too strict. The old check was StorageType equality, which seems perhaps too lax...

Is what we want "MemType equality except that we consider all pointer types the same?" I'm not sure...

My only hesitation about developing a separate compatibleTypes predicate is that the more similar-but-not-quite-the-same checks we have, the more likely they get out of sync.

@langston-barrett
Copy link
Contributor Author

langston-barrett commented May 17, 2019

@robdockins Thanks for clarifying that (I think you told me once and I forgot 😅)

This is an uncomfortable middle ground. I would think that we want MemType equality modulo special treatment of SetupNull, at least that would work for both the above examples.

@langston-barrett
Copy link
Contributor Author

langston-barrett commented May 17, 2019

Rob and I had a conversation in which he convinced me that "MemType equality except that we consider all pointer types the same"* is probably what we want. We raised zero initialization of structs as an important example to keep in mind.

* "... possibly with a warning if the pointer types aren't on-the-nose the same, but probably no warning if one of them was the null pointer..."

@langston-barrett langston-barrett added this to the 0.3 milestone May 24, 2019
langston-barrett added a commit that referenced this issue May 24, 2019
This is a spot fix. The check we have right now is too strict, it won't even let
you specify that a function returns `crucible_null`.

See #443, which we should leave open until we implement the proper check
described there.
@langston-barrett langston-barrett modified the milestones: 0.3, 1.0 May 24, 2019
atomb pushed a commit that referenced this issue May 28, 2019
This is a spot fix. The check we have right now is too strict, it won't even let
you specify that a function returns `crucible_null`.

See #443, which we should leave open until we implement the proper check
described there.
@langston-barrett langston-barrett changed the title Crucible/LLVM: Return type checking is too strict Crucible/LLVM: Return type checking is too lax Jun 6, 2019
@langston-barrett
Copy link
Contributor Author

We changed it back to checkRegisterCompatibility in #463 to get ready for 0.3, but as noted above this check is too lax, and causes panics in our simulator if the user has ill-typed SAWscript code.

@langston-barrett langston-barrett added the subsystem: crucible-llvm Issues related to LLVM bitcode verification with crucible-llvm label Jun 7, 2019
@atomb atomb self-assigned this Apr 17, 2020
@atomb atomb modified the milestones: 0.5, 0.6 Apr 21, 2020
@atomb atomb modified the milestones: 0.6, 0.7 Aug 21, 2020
@atomb atomb modified the milestones: 0.7, 0.8 Dec 14, 2020
@atomb atomb modified the milestones: 0.8, 0.9 Apr 16, 2021
@atomb atomb removed this from the 0.9 milestone Sep 22, 2021
@atomb atomb removed their assignment Oct 19, 2021
@sauclovian-g sauclovian-g added type: bug Issues reporting bugs or unexpected/unwanted behavior needs test Issues for which we should add a regression test topics: error-handling Issues involving the way SAW responds to an error condition labels Oct 29, 2024
@sauclovian-g sauclovian-g added this to the 2025T1 milestone Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs test Issues for which we should add a regression test subsystem: crucible-llvm Issues related to LLVM bitcode verification with crucible-llvm topics: error-handling Issues involving the way SAW responds to an error condition type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

No branches or pull requests

4 participants