Re: pg15b3: crash in paralell vacuum - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: pg15b3: crash in paralell vacuum
Date
Msg-id CAH2-WzkhhE1gXi0=Q2d5geYX+aabK0MidmyzTN+AvebLOhihYA@mail.gmail.com
Whole thread Raw
In response to Re: pg15b3: crash in paralell vacuum  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
On Thu, Aug 18, 2022 at 7:25 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> Justin, if it's reproducible in your environment, could you please try
> it again with the attached patch?

Pushed, thanks.

I wonder how this issue could have been caught earlier, or even
avoided in the first place. Would the bug have been caught if Valgrind
had known to mark dynamic shared memory VALGRIND_MAKE_MEM_UNDEFINED()
when it is first allocated? ISTM that we should do something that is
analogous to aset.c's Valgrind handling for palloc() requests.

Similar work on buffers in shared memory led to us catching a tricky
bug involving unsafe access to a buffer, a little while ago -- see
bugfix commit 7b7ed046. The bug in question would probably have taken
much longer to catch without the instrumentation. In fact, it seems
like a good idea to use Valgrind for *anything* where it *might* catch
bugs, just in case.

Valgrind can work well for shared memory without any extra work. The
backend's own idea of the memory (the memory mapping used by the
process) is all that Valgrind cares about. You don't have to worry
about Valgrind instrumentation in one backend causing confusion in
another backend. It's very practical, and very general purpose. I
think that most of the protection comes from a basic understanding of
"this memory is unsafe to access, this memory contains uninitialized
data that cannot be assumed to have any particular value, this memory
is initialized and safe".

--
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: shadow variables - pg15 edition
Next
From: Justin Pryzby
Date:
Subject: Re: Cirrus CI (Windows help wanted)