Clear MyProc and MyProcSignalState before they become invalid.
authorRobert Haas <rhaas@postgresql.org>
Sat, 1 Feb 2014 02:31:08 +0000 (21:31 -0500)
committerRobert Haas <rhaas@postgresql.org>
Sat, 1 Feb 2014 02:34:44 +0000 (21:34 -0500)
commit5d807a74bf66ba9fb4f55e49e7c601b0b9804123
tree2b9893b448e4f22702549b8d29c31291d242d409
parent5dc6cab2d2b92bb066291a28d856d37d53e3a944
Clear MyProc and MyProcSignalState before they become invalid.

Evidence from buildfarm member crake suggests that the new test_shm_mq
module is routinely crashing the server due to the arrival of a SIGUSR1
after the shared memory segment has been unmapped.  Although processes
using the new dynamic background worker facilities are more likely to
receive a SIGUSR1 around this time, the problem is also possible on older
branches, so I'm back-patching the parts of this change that apply to
older branches as far as they apply.

It's already generally the case that code checks whether these pointers
are NULL before deferencing them, so the important thing is mostly to
make sure that they do get set to NULL before they become invalid.  But
in master, there's one case in procsignal_sigusr1_handler that lacks a
NULL guard, so add that.

Patch by me; review by Tom Lane.
src/backend/storage/ipc/procsignal.c
src/backend/storage/lmgr/proc.c