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

Bounds checking bounds-safe interfaces in unchecked scopes #1169

Merged
merged 12 commits into from Aug 30, 2021

Conversation

kkjeer
Copy link
Contributor

@kkjeer kkjeer commented Aug 24, 2021

Fixes #1158

This PR updates the bounds checking behavior for lvalue expressions with bounds-safe interfaces in unchecked scopes.

If:

  1. A statement S is in an unchecked scope, and:
  2. An lvalue expression e has unchecked pointer type (its bounds were declared using a bounds-safe interface), and:
  3. S does not contain an assignment e = e1 where e1 is a checked pointer, then:

The bounds of e are not validated after checking S.

kakje added 10 commits August 23, 2021 15:14
LValuesAssignedChecked contains AbstractSets representing lvalues expressions that have unchecked pointer type that were assigned a checked pointer during the current top-level statement (if the statement is in an unchecked scope). AbstractSets in LValuesAssignedChecked should have their bounds validated after checking the current statement.
Copy link
Contributor

@sulekhark sulekhark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (there's just one minor comment)! Thank you!

p += i;

// The type of the RHS expression p + r is int *, so a checked pointer is not
// assigned to p here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the code that the comment on lines 841 and 842 is referring to is missing (not sure).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on lines 841 and 842 is referring to the code on line 843, since the type of the RHS expression p - (_Array_ptr<int>)q is int *.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment has a typo, so I'll update the comment - thanks for catching this!

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

Successfully merging this pull request may close these issues.

Do not emit bounds checking warnings or errors for bounds-safe interfaces in certain contexts
2 participants