Fix possible double-release of spinlock in procsignal.c 9d9b9d46f3c5 has added spinlocks to protect the fields in ProcSignal flags, introducing a code path in ProcSignalInit() where a spinlock could be released twice if the pss_pid field of a ProcSignalSlot is found as already set. Multiple spinlock releases have no effect with most spinlock implementations, but this could cause the code to run into issues when the spinlock is acquired concurrently by a different process.
This sanity check on pss_pid generates a LOG that can be delayed until after the spinlock is released as, like older versions up to v17, the code expects the initialization of the ProcSignalSlot to happen even if pss_pid is found incorrect. The code is changed so as the old pss_pid is read while holding the slot's spinlock, with the LOG from the sanity check generated after releasing the spinlock, preventing the double release. Author: Maksim Melnikov <m.melni...@postgrespro.ru> Co-authored-by: Maxim Orlov <orlo...@gmail.com> Reviewed-by: Andrey Borodin <x4...@yandex-team.ru> Discussion: https://postgr.es/m/dca47527-2d8b-4e3b-b5a0-e2deb7337...@postgrespro.ru Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/62ec3e1f6786181431210643a2d427b9a98b8af8 Modified Files -------------- src/backend/storage/ipc/procsignal.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)