News for hackers. Stuff that matters.
Re:Flattening ASTs (and Other Compiler Data Structures) by chubot on Monday July 03, 2023 @12:28PM (#36575259)
Yes, I mentioned the same issue a few days ago -- arenas break ASAN/Valgrind, and those are the BEST tools to ensure memory safety:

https://news.ycombinator.com/item?id=36427264

In response to a claim about arena-based allocators and memory safety

Re:Flattening ASTs (and Other Compiler Data Structures) by kazinator on Monday July 03, 2023 @01:19PM (#36576063)
Maybe Valgrind has an API now to attach a backtrace to a custom allocation out of an arena. I haven't touched that in years. I did the initial Valgrind integration in 2009 and just maintained it with changes to the gc.

I see this in the current manual:

VALGRIND_MALLOCLIKE_BLOCK:

If your program manages its own memory instead of using the standard malloc / new / new[], tools that track information about heap blocks will not do nearly as good a job. For example, Memcheck won't detect nearly as many errors, and the error messages won't be as informative. To improve this situation, use this macro just after your custom allocator allocates some new memory. See the comments in valgrind.h for information on how to use it.

I can't remember whether I saw this before; i.e. is this something existing that had not been useful, or is it something new. I will look into it.

It does look like it should be attacking the same problem: that the errors aren't detected well or nearly as informative in blocks carved out of larger block by custom allocators.

Re:Flattening ASTs (and Other Compiler Data Structures) by kazinator on Tuesday July 04, 2023 @07:37PM (#36593864)
* * *