bustub icon indicating copy to clipboard operation
bustub copied to clipboard

Verify `TriviallyCopyable` on all buffer page kinds

Open connortsui20 opened this issue 6 months ago • 0 comments

Right now, there is no guardrail against adding a member/field that might not be trivially copyable to a buffer page. For example, students can add shared_ptr or a mutex or even a vector into a buffer page like one of the B+ Tree internal node pages.

Adding a type that makes an allocation (for example a vector) into a buffer page is immediately a memory leak once that buffer page is evicted or dropped. When that page comes back, I guess you just have to hope that the memory is still there and still valid. And in the case of shared_ptr I'm pretty sure that is immediately UB.

We can add a static assert with is_trivially_copyable on to all of the page kinds to make sure this does not happen.

connortsui20 avatar Jun 18 '25 05:06 connortsui20