Hi, On 2026-01-22 11:09:37 +0500, Andrey Borodin wrote: > > On 22 Jan 2026, at 06:56, Andres Freund <[email protected]> wrote: > > > > It'd be nice to teach > > the compile that palloc allocates, to a) get compiler warnings for things > > like > > use-after-free b) warnings for things like access-beyond-allocation. > > Is there any chance to teach a compiler about short lived memory contexts?
I doubt that we can teach static analysis that anytime soon - I think you'd need a compiler plugin for that. However I'd already be happy with getting warnings for obvious stuff like using variables after being pfreed (even indirectly) or running off the end of an allocation. We certainly could improve the sanitizer integration with memory contexts, but that obviously requires reaching the relevant paths in a problematic scenario to be effective. Greetings, Andres Freund
