oceanbase / miniob

MiniOB is a compact database that assists developers in understanding the fundamental workings of a database.
https://oceanbase.github.io/miniob/
Mulan Permissive Software License, Version 2
2.86k stars 1.01k forks source link

ASAN 与 内存池结合的问题 #380

Open hnwyllmm opened 3 weeks ago

hnwyllmm commented 3 weeks ago

Enhancement ASAN可以非常方便的帮我们发现并排查很多内存泄露、越界等问题。但是当我们使用了内存池,ASAN无法识别一个对象的边界,此时如果出现内存越界,ASAN 无法发现问题。 需要找到使用内存池也能使用ASAN发现问题的方法。

当前的内存池实现是mem_pool.h,BPFrameManager 使用了内存池。

测试:可以写一个单测来模拟mem_pool越界行为,看是否能够暴露出问题。

一些参考资料: 代码库:https://github.com/google/sanitizers ASAN的介绍文档:https://github.com/google/sanitizers/wiki/AddressSanitizer 附近会有一些相关内容 AddressSanitizerManualPoisoning Manual Memory Poisoning with ASAN Memory pool should be manually poisoned so that ASAN works with it 看起来参考这个文档,在申请内存和释放内存的时候,执行asan的posion和unposion接口就可以。

memorypool: fixed: unpoison memory for ASAN befor