From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: NULL passed as an argument to memcmp() in parse_func.c |
Date: | 2015-06-22 21:05:20 |
Message-ID: | CA+TgmoZgksPwPKMt+s-8LquuUTRx_phckc0Q62pHFP0Nafk=mw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jun 22, 2015 at 2:55 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me> writes:
>> There are two places in parse_func.c where memcmp() conditionally gets a
>> NULL as its first argument, which invokes undefined behavior. I guess
>> gcc -O2 will make some assumptions based on memcpy's __nonnull attribute.
>
> If I recall that code correctly, the assumption was that if the third
> argument is zero then memcmp() must not fetch any bytes (not should not,
> but MUST not) and therefore it doesn't matter if we pass a NULL. Are
> you seeing any observable problem here, and if so what is it?
I dunno, this seems like playing with fire to me. A null-test would
be pretty cheap insurance.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Rajeev rastogi | 2015-06-22 21:14:01 | Re: 9.5 release notes |
Previous Message | Robert Haas | 2015-06-22 21:03:40 | Re: RFC: replace pg_stat_activity.waiting with something more descriptive |