RE: [BUG] (firsttupleslot)==NULL is redundant or is possible null dereference?

From: Ranier Vilela <ranier_gyn(at)hotmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: [BUG] (firsttupleslot)==NULL is redundant or is possible null dereference?
Date: 2019-11-23 03:38:23
Message-ID: MN2PR18MB29277475FE1330608B738C93E3480@MN2PR18MB2927.namprd18.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>And why do you think this is a bug? Immediately before the part of code
>you copied we have this:
>
> /*
> * The ScanTupleSlot holds the (copied) first tuple of each group.
> */
> firsttupleslot = node->ss.ss_ScanTupleSlot;
>And node->ss.ss_ScanTupleSlot is expected to be non-NULL. So the initial
>assumption that firsttupleslot is NULL is incorrect.

IMHO, the test could be improved, this way it silences the scan tool.

--- \dll\postgresql-12.0\a\backend\executor\nodeGroup.c Mon Sep 30 17:06:55 2019
+++ nodeGroup.c Sat Nov 23 00:23:27 2019
@@ -64,7 +64,7 @@
* If first time through, acquire first input tuple and determine whether
* to return it or not.
*/
- if (TupIsNull(firsttupleslot))
+ if ((firsttupleslot != NULL) && TTS_EMPTY(firsttupleslot))
{
outerslot = ExecProcNode(outerPlanState(node));
if (TupIsNull(outerslot))

best regards.
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2019-11-23 05:53:26 Re: Ordering of header file inclusion
Previous Message Mark Dilger 2019-11-23 00:01:15 Re: Assertion failing in master, predicate.c