Skip to content

[BoundsSafety] Bring full support for -fbounds-safety #9707

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

Conversation

rapidsna
Copy link

@rapidsna rapidsna commented Dec 9, 2024

-fbounds-safety is a C extension to enforce bounds safety to prevent out-of-bounds (OOB) memory accesses. The extension offers bounds annotations that programmers can use to attach bounds to pointers. Using this bounds information, the compiler inserts bounds checks on every pointer dereference, ensuring that the program does not access memory outside the specified bounds. The compiler requires programmers to provide enough bounds information so that the accesses can be checked at either run time or compile time — and it rejects code if it cannot.

For more details, please refer to

RFC discussions: https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-c-fbounds-safety/70854
The design documentation: https://clang.llvm.org/docs/BoundsSafety.html
The bounds annotations provided by -fbounds-safety could potentially be useful to implement safe interoperation between C/C++ and safe languages such as Swift. Similar to lifetime dependency annotations as pitched here.

This patch contains collaborative work from @rapidsna @apple-fcloutier @patrykstefanski @delcypher @hnrklssn and from many other collaborators from the optimization and debugger side of support.

Cherry-picking #9679

@rapidsna
Copy link
Author

rapidsna commented Dec 9, 2024

@swift-ci test

@rapidsna
Copy link
Author

rapidsna commented Dec 9, 2024

@swift-ci test llvm

@rapidsna rapidsna marked this pull request as ready for review December 9, 2024 08:59
@rapidsna rapidsna requested a review from a team as a code owner December 9, 2024 08:59
@rapidsna rapidsna force-pushed the dev/yeoulna/upstream-bounds-safety-swift/stable/20240723 branch from 5d82e93 to dd0235d Compare December 10, 2024 06:55
@rapidsna
Copy link
Author

@swift-ci test

@rapidsna
Copy link
Author

@swift-ci test llvm

@rapidsna rapidsna force-pushed the dev/yeoulna/upstream-bounds-safety-swift/stable/20240723 branch from dd0235d to 6057a1d Compare December 10, 2024 11:30
@rapidsna
Copy link
Author

@swift-ci test

@rapidsna rapidsna merged commit be88cf9 into stable/20240723 Dec 11, 2024
3 checks passed
@rapidsna rapidsna deleted the dev/yeoulna/upstream-bounds-safety-swift/stable/20240723 branch December 11, 2024 04:38
@rapidsna
Copy link
Author

@swift-ci test llvm

@drodriguez
Copy link

From previous experience, "test llvm" doesn't work after merge. You might want to submit a bogus PR to retest, but https://ci.swift.org/view/Pull%20Requests/job/pr-apple-llvm-project-llvm-linux/ shows the failures happening in the Linux builds of other PRs that are testing LLVM.

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.

3 participants