On Tue, Aug 7, 2018 at 6:43 PM, Asim R P <aprav...@pivotal.io> wrote: > Please find attached a patch to mark a shared buffer as read-write or > read-only using mprotect(). The idea is to catch violations of shared > buffer access rules. This patch was useful to detect the access > violations reported in this thread. The mprotect() calls are enabled > by -DMPROTECT_BUFFER compile time flag.
I wonder if it would be a better idea to enable Valgrind's memcheck to mark buffers as read-only or read-write. We've considered doing something like that for years, but for whatever reason nobody followed through. Using Valgrind would have the advantage of making it possible to mark memory as undefined or as noaccess. I can imagine doing even fancier things by making that distinction within buffers. For example, marking the hole in the middle of a page/buffer as undefined, while still marking the entire buffer noaccess when there is no pin held. -- Peter Geoghegan