Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-07-01 Thread Andres Freund
On 2015-07-01 10:51:49 -0400, Tom Lane wrote: The problem is that there are multiple risks to manage here. If I were to back-patch that patch, it would actively break any third-party extensions that might be using the formerly-considered-valid technique of passing a NULL array pointer to

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-07-01 Thread Tom Lane
Piotr Stefaniak postg...@piotr-stefaniak.me writes: On 06/27/2015 11:47 PM, Tom Lane wrote: Given the utter lack of any evidence that this actually causes any problems in the field, I don't feel a need to back-patch this change. I'm under the impression that you don't care about not avoiding

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-07-01 Thread Tom Lane
Andres Freund and...@anarazel.de writes: On 2015-07-01 10:51:49 -0400, Tom Lane wrote: The problem is that there are multiple risks to manage here. If I were to back-patch that patch, it would actively break any third-party extensions that might be using the formerly-considered-valid

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-06-23 Thread Tom Lane
Glen Knowles gknow...@ieee.org writes: It appears that, according to the standard, passing NULL to memcmp is undefined behavior, even if the count is 0. See http://stackoverflow.com/questions/16362925/can-i-pass-a-null-pointer-to-memcmp for C99 and C++ standard references. Hmm ... looks like

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-06-23 Thread Glen Knowles
It appears that, according to the standard, passing NULL to memcmp is undefined behavior, even if the count is 0. See http://stackoverflow.com/questions/16362925/can-i-pass-a-null-pointer-to-memcmp for C99 and C++ standard references. I didn't see a good reference for C89 but I find it almost

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-06-22 Thread Robert Haas
On Mon, Jun 22, 2015 at 2:55 PM, Tom Lane t...@sss.pgh.pa.us wrote: Piotr Stefaniak postg...@piotr-stefaniak.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

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-06-22 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Mon, Jun 22, 2015 at 2:55 PM, Tom Lane t...@sss.pgh.pa.us wrote: 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

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-06-22 Thread Tom Lane
Piotr Stefaniak postg...@piotr-stefaniak.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

Re: [HACKERS] NULL passed as an argument to memcmp() in parse_func.c

2015-06-22 Thread Tom Lane
Piotr Stefaniak postg...@piotr-stefaniak.me writes: On 06/22/2015 08:55 PM, Tom Lane wrote: 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