Skip to content

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

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

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

rapidsna
Copy link

@rapidsna rapidsna commented Dec 3, 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 #9665

@rapidsna
Copy link
Author

rapidsna commented Dec 3, 2024

@swift-ci test

@rapidsna
Copy link
Author

rapidsna commented Dec 3, 2024

@swift-ci llvm test

@rapidsna
Copy link
Author

rapidsna commented Dec 4, 2024

@swift-ci test

@rapidsna
Copy link
Author

rapidsna commented Dec 4, 2024

@swift-ci llvm test

@rapidsna rapidsna force-pushed the dev/yeoulna/upstream-bounds-safety-swift/next branch from 6ad5c0c to 0066b9a Compare December 4, 2024 07:56
@rapidsna
Copy link
Author

rapidsna commented Dec 4, 2024

@swift-ci test

@rapidsna
Copy link
Author

rapidsna commented Dec 4, 2024

@swift-ci llvm test

@rapidsna
Copy link
Author

rapidsna commented Dec 5, 2024

@swift-ci test

@rapidsna rapidsna force-pushed the dev/yeoulna/upstream-bounds-safety-swift/next branch from 0066b9a to 5f998b8 Compare December 5, 2024 01:56
@rapidsna
Copy link
Author

rapidsna commented Dec 5, 2024

@swift-ci test

@rapidsna
Copy link
Author

rapidsna commented Dec 5, 2024

@swift-ci test llvm

@rapidsna rapidsna force-pushed the dev/yeoulna/upstream-bounds-safety-swift/next branch from 7d29e29 to bdb1166 Compare December 5, 2024 05:16
@delcypher delcypher added the clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang label Dec 6, 2024
@rapidsna rapidsna force-pushed the dev/yeoulna/upstream-bounds-safety-swift/next branch from 260d5e5 to a4d868b Compare December 10, 2024 07:28
@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/next branch 2 times, most recently from 607cee7 to 0920fa1 Compare December 10, 2024 08:51
@rapidsna
Copy link
Author

@swift-ci test

@rapidsna rapidsna force-pushed the dev/yeoulna/upstream-bounds-safety-swift/next branch from 0920fa1 to 4554416 Compare December 10, 2024 11:32
@rapidsna
Copy link
Author

@swift-ci test

Copy link

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

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

Debug info / LLDB parts LGTM.

@rapidsna rapidsna merged commit 7004047 into next Dec 11, 2024
0 of 3 checks passed
@rapidsna rapidsna deleted the dev/yeoulna/upstream-bounds-safety-swift/next branch December 11, 2024 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants