Stop reading uninitialized memory in heap_inplace_lock().
authorNoah Misch <noah@leadboat.com>
Thu, 24 Oct 2024 16:16:14 +0000 (09:16 -0700)
committerNoah Misch <noah@leadboat.com>
Thu, 24 Oct 2024 16:16:14 +0000 (09:16 -0700)
Stop computing a never-used value.  This removes the read; the read had
no functional implications.  Back-patch to v12, like commit
a07e03fd8fa7daf4d1356f7cb501ffe784ea6257.

Reported by Alexander Lakhin.

Discussion: https://postgr.es/m/6c92f59b-f5bc-e58c-9bdd-d1f21c17c786@gmail.com

src/backend/access/heap/heapam.c
src/test/isolation/expected/intra-grant-inplace.out
src/test/isolation/specs/intra-grant-inplace.spec

index da5e656a08de40ccbfdb68d783995a273b73b5fa..82a0492aac5fde54c9deee37b3e075af84f633b9 100644 (file)
@@ -6260,10 +6260,9 @@ heap_inplace_lock(Relation relation,
            LockTupleMode lockmode = LockTupleNoKeyExclusive;
            MultiXactStatus mxact_status = MultiXactStatusNoKeyUpdate;
            int         remain;
-           bool        current_is_member;
 
            if (DoesMultiXactIdConflict((MultiXactId) xwait, infomask,
-                                       lockmode, &current_is_member))
+                                       lockmode, NULL))
            {
                LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
                ret = false;
index b5fe8b06f76184148bac4efeb9736c0d3da0d5ab..4e9695a02146c0a15adf1e94a6093e6fe9ab70c6 100644 (file)
@@ -63,6 +63,30 @@ step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c); <waiting ...>
 step r3: ROLLBACK;
 step addk2: <... completed>
 
+starting permutation: b3 sfnku3 keyshr5 addk2 r3
+step b3: BEGIN ISOLATION LEVEL READ COMMITTED;
+step sfnku3: 
+   SELECT relhasindex FROM pg_class
+   WHERE oid = 'intra_grant_inplace'::regclass FOR NO KEY UPDATE;
+
+relhasindex
+-----------
+f          
+(1 row)
+
+step keyshr5: 
+   SELECT relhasindex FROM pg_class
+   WHERE oid = 'intra_grant_inplace'::regclass FOR KEY SHARE;
+
+relhasindex
+-----------
+f          
+(1 row)
+
+step addk2: ALTER TABLE intra_grant_inplace ADD PRIMARY KEY (c); <waiting ...>
+step r3: ROLLBACK;
+step addk2: <... completed>
+
 starting permutation: b2 sfnku2 addk2 c2
 step b2: BEGIN;
 step sfnku2: 
index 2992c85b44ddaf46ba0476a6a2199e3db63c213e..9936d389359e5f051c94621a5ff3dad35b049485 100644 (file)
@@ -96,6 +96,14 @@ permutation
    addk2(r3)
    r3
 
+# reproduce bug in DoesMultiXactIdConflict() call
+permutation
+   b3
+   sfnku3
+   keyshr5
+   addk2(r3)
+   r3
+
 # same-xact rowmark
 permutation
    b2