TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Tip of the day #2: A safer arena allocator

23 点作者 broken_broken_7 个月前

2 条评论

GuB-426 个月前
It is wrong to just use malloc() to make the arena? This way, sanitizers will still help you a bit. It will not help with everything you do within the arena, but it may detect it if you access outside the arena, like the problem the author has.<p>Other than that, I think using guard pages is the technique libefence (electric fence) uses.
mananaysiempre6 个月前
If you want to go further, ASAN and Valgrind both have APIs for integrating custom allocators. So you basically do what ASAN does with malloc in the first place—allocate (a bit more) memory, poison it, then pad all user allocations on both ends and only unpoison the actually requested part.