-
Notifications
You must be signed in to change notification settings - Fork 4
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
Clarify handling of out-of-bounds memory access #107
Comments
This is simply an invalid CoreDSL description so the validator needs to flag it. Since sizes are defined there can be proper bounds checking implemented in the parser/validator. So no backend handling should be needed... |
And how about these cases?
|
@eyck That is incorrect. I can emit warnings if the value of the index expression is known at validation time, but that will not be the general case. edit: Just checked and those warnings are already implemented. |
For range accesses into address spaces and bit vectors it currently states that result is undefined if the range falls outside the bounds of the indexed element. I believe this is a sensible rule that should be extended to not only cover the range operator, but also the normal index access operator. Also the specification currently does not mention indexing into arrays, but that should generally follow the same rules as well. I propose the following changes to the specification: Currently:
Proposed:
|
Hmm, in the first case the range is 0-31. It can be detected and reported If the length of X is smaller than 32. Aside of this I agree with @AtomCrafty that we should update the spec. |
From a language perspective, Using the type of the indexing expression to deduce possible value ranges like you suggest is not supported by the frontend. That would be a major new feature we could possibly add down the road, but it is not feasible right now. Also note that this could only ever be used to flag a small subset of expressions as "definitely unproblematic" and would not be generally able to decide whether an access could possibly be out of bounds at runtime. Deciding that would require a symbolic solver, which is far outside the scope of a language frontend. |
Given a
register unsigned<XLEN> X[16]
what should happen when someone tries to useX[25]
in the behavior? This specific case might occur depending on what we end up for #94.What do you think? @eyck @AtomCrafty @wysiwyng
The text was updated successfully, but these errors were encountered: