ancient sequence point bug

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ancient sequence point bug
Date: 2013-04-17 02:35:31
Message-ID: 1366166131.8318.10.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This code in bootstrap.c contains a sequence point violation (or
whatever that is really called):

while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
(*app)->am_oid = HeapTupleGetOid(tup);
memmove((char *) &(*app++)->am_typ,
(char *) GETSTRUCT(tup),
sizeof((*app)->am_typ));
}

In commit 1aebc361, another place in the same file was fixed like this:

@@ -445,13 +455,13 @@ struct typmap
while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
{
(*app)->am_oid = tup->t_data->t_oid;
- memmove((char *) &(*app++)->am_typ,
- (char *) GETSTRUCT(tup),
- sizeof((*app)->am_typ));
+ memcpy((char *) &(*app)->am_typ,
+ (char *) GETSTRUCT(tup),
+ sizeof((*app)->am_typ));
+ app++;
}
heap_endscan(scan);
heap_close(rel, NoLock);

I think the same (move the app++, and change to memcpy (optionally))
should be done in the first case as well.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-04-17 02:51:39 Re: ancient sequence point bug
Previous Message Florian Pflug 2013-04-16 23:26:01 Re: Enabling Checksums