0001-Fix-the-seg-fault-during-proc-exit.patch
application/octet-stream
Filename: 0001-Fix-the-seg-fault-during-proc-exit.patch
Type: application/octet-stream
Part: 1
From b6fd0117202dc141abc7fc28a2574ea5934c91fb Mon Sep 17 00:00:00 2001
From: Rahila Syed <rahilasyed.90@gmail.com>
Date: Fri, 21 Nov 2025 15:37:19 +0530
Subject: [PATCH] Fix the seg fault during proc exit
If a process encounters a FATAL error after
acquiring a dshash lock but before releasing it,
and it is not within a transaction, it can lead
to a segmentation fault.
Call LWLockReleaseAll() from shmem_exit()
---
src/backend/storage/ipc/ipc.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c
index 2704e80b3a7..68cf096514c 100644
--- a/src/backend/storage/ipc/ipc.c
+++ b/src/backend/storage/ipc/ipc.c
@@ -29,6 +29,7 @@
#endif
#include "storage/dsm.h"
#include "storage/ipc.h"
+#include "storage/lwlock.h"
#include "tcop/tcopprot.h"
@@ -229,6 +230,14 @@ shmem_exit(int code)
{
shmem_exit_inprogress = true;
+ /*
+ * Make sure we release any pending locks so that any callbacks called
+ * subsequently do not fail to acquire any locks. This also fixes a seg
+ * fault due to releasing a dshash lock after the dsm segment containing
+ * the lock has been detached by dsm_backend_shutdown().
+ */
+ LWLockReleaseAll();
+
/*
* Call before_shmem_exit callbacks.
*
--
2.34.1