[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1109672: unblock: pg-show-plans/2.1.5-2



Package: release.debian.org
Severity: normal
X-Debbugs-Cc: pg-show-plans@packages.debian.org
Control: affects -1 + src:pg-show-plans
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package pg-show-plans

[ Reason ]
Fix possible spinlock leakage.
https://github.com/cybertec-postgresql/pg_show_plans/issues/46

[ Tests ]
Package passes tests.

[ Checklist ]
  [x] all changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in testing

unblock pg-show-plans/2.1.5-2

Thanks,
Christoph


diff -Nru pg-show-plans-2.1.5/debian/changelog pg-show-plans-2.1.5/debian/changelog
--- pg-show-plans-2.1.5/debian/changelog	2025-05-12 11:35:08.000000000 +0200
+++ pg-show-plans-2.1.5/debian/changelog	2025-07-21 11:58:29.000000000 +0200
@@ -1,3 +1,9 @@
+pg-show-plans (2.1.5-2) unstable; urgency=medium
+
+  * Fix possible spinlock leakage.
+
+ -- Christoph Berg <myon@debian.org>  Mon, 21 Jul 2025 11:58:29 +0200
+
 pg-show-plans (2.1.5-1) unstable; urgency=medium

   * New upstream version 2.1.5.
diff -Nru pg-show-plans-2.1.5/debian/patches/6c8b1037e4a9c54c72861d400a9bb4c360a983a6 pg-show-plans-2.1.5/debian/patches/6c8b1037e4a9c54c72861d400a9bb4c360a983a6
--- pg-show-plans-2.1.5/debian/patches/6c8b1037e4a9c54c72861d400a9bb4c360a983a6	1970-01-01 01:00:00.000000000 +0100
+++ pg-show-plans-2.1.5/debian/patches/6c8b1037e4a9c54c72861d400a9bb4c360a983a6	2025-07-21 11:58:29.000000000 +0200
@@ -0,0 +1,58 @@
+commit 6c8b1037e4a9c54c72861d400a9bb4c360a983a6
+Author: Ivan Kovmir <i@kovmir.eu>
+Date:   Mon Jul 21 10:42:17 2025 +0200
+
+    Fix possible spinlock leakage
+
+    * Spinlock is held longer than it is allowed to be.
+    * `heap_form_tuple()` may raise errors while the lock is being held,
+       which could result in spinlock leakage.
+
+    Thanks https://github.com/ocean-dot-li
+    Close #46.
+
+--- a/pg_show_plans.c
++++ b/pg_show_plans.c
+@@ -68,6 +68,7 @@ typedef struct pgspCtx { /* Used as `fun
+ 	pgspEntry       *pgsp_tmp_entry; /* PGSP entry currently processing. */
+ 	int              curr_nest; /* Current nest level porcessing. */
+ 	bool             is_done; /* Done processing current PGSP entry? */
++	int				 n_plans;
+ } pgspCtx;
+
+ /* Function Prototypes */
+@@ -611,6 +612,7 @@ pg_show_plans(PG_FUNCTION_ARGS)
+ 		pgsp_ctx = (pgspCtx *)palloc(sizeof(pgspCtx));
+ 		pgsp_ctx->is_done = true;
+ 		pgsp_ctx->curr_nest = 0;
++		pgsp_ctx->n_plans = 0;
+ 		pgsp_ctx->hash_seq = (HASH_SEQ_STATUS *)palloc(sizeof(HASH_SEQ_STATUS));
+ 		hash_seq_init(pgsp_ctx->hash_seq, pgsp_hash);
+ 		funcctx->user_fctx = (void *)pgsp_ctx;
+@@ -663,6 +665,8 @@ pg_show_plans(PG_FUNCTION_ARGS)
+ 				call_cntr++;
+ 			}
+ 			SpinLockAcquire(&pgsp_tmp_entry->mutex);
++			pgsp_ctx->n_plans = pgsp_tmp_entry->n_plans;
++			SpinLockRelease(&pgsp_tmp_entry->mutex);
+ 		}
+
+ 		/* A single hash entry may store multiple (nested) plans, so
+@@ -679,7 +683,7 @@ pg_show_plans(PG_FUNCTION_ARGS)
+ 		values[4] = CStringGetTextDatum(pgsp_tmp_entry->plan + offset);
+ 		htup = heap_form_tuple(funcctx->tuple_desc, values, nulls);
+
+-		if (curr_nest < pgsp_tmp_entry->n_plans-1)
++		if (curr_nest < pgsp_ctx->n_plans - 1)
+ 		{ /* Still have nested plans. */
+ 			curr_nest++;
+ 			call_cntr--; /* May not be legal, but it works. */
+@@ -687,7 +691,7 @@ pg_show_plans(PG_FUNCTION_ARGS)
+ 		} else { /* No more nested plans, get a new entry. */
+ 			curr_nest = 0;
+ 			is_done = true;
+-			SpinLockRelease(&pgsp_tmp_entry->mutex);
++			pgsp_ctx->n_plans = 0;
+ 		}
+ 		/* Save values back to the context. */
+ 		pgsp_ctx->is_done = is_done;
diff -Nru pg-show-plans-2.1.5/debian/patches/series pg-show-plans-2.1.5/debian/patches/series
--- pg-show-plans-2.1.5/debian/patches/series	1970-01-01 01:00:00.000000000 +0100
+++ pg-show-plans-2.1.5/debian/patches/series	2025-07-21 11:58:29.000000000 +0200
@@ -0,0 +1 @@
+6c8b1037e4a9c54c72861d400a9bb4c360a983a6


Reply to: