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

2015-07-01 Thread Tom Lane
Andres Freund 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 technique of passing

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 t

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

2015-07-01 Thread Tom Lane
Piotr Stefaniak 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 > undefined behavior

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

2015-06-23 Thread Tom Lane
Glen Knowles 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 that's correct

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

2015-06-22 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 impos

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

2015-06-22 Thread Tom Lane
Robert Haas writes: > On Mon, Jun 22, 2015 at 2: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 NULL. Are >> y

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 wrote: > Piotr Stefaniak 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 attribu

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

2015-06-22 Thread Tom Lane
Piotr Stefaniak 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 NULL. > It's not abo

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

2015-06-22 Thread Tom Lane
Piotr Stefaniak 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