bustub
bustub copied to clipboard
[Proposal]: Add LLVM Thread Safety Analyzer annotations for better developer experience + safety
You can add some annotations to mutexes when using Clang, and in exchange get static checking for correctness (to a degree) This is separate from TSAN runtime checks:
- https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
- Then you can add
-Wthread-safety -Wthread-safety-beta
to compile flags
For example, here I annotate page_table
here with GUARDED_BY(mutex)
, then it tells me in get_frame
that I can't read/write to page_table
without holding the mutex
guarding it:
https://user-images.githubusercontent.com/26604994/190878150-1174a1fe-8699-4126-afdf-bbf8d827f204.mp4
That's great!!! This is one of the most functionality that I've missed from the Rust programming language when I started to work on the BusTub project.
But we have already started project 1. Code from project 1 will be used throughout the semester. I'd postpone this to next semester.