Re: clang's static checker report.

Lists: pgsql-hackers
From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: clang's static checker report.
Date: 2009-08-23 15:57:58
Message-ID: B69D9C3D-1E5A-4D53-9C7F-C894F1FC1469@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

So,

after successful, and helpful Saturday with llvm's clang static
checker, I decided to run it against postgresql's source code.
Result can be seen at: http://zlew.org/postgresql_static_check/scan-build-2009-08-23-5/
.
One directory below is the tar file, with the report.

I am sure there's plenty of false positives, but I am also quite sure
there's many real errors on that list. As I have rather bad
experiences with any patches sent here - I hope that's least I can
help with.

To run clang-check I had to change one of the makefiles slightly, as
the postgresql's build system seems to ignore $CC variable
completely , always sticking to the one chosen by the configure script.

The changed file is ./src/Makefile.global. Around line 210 I included
ifdef CC, like that:

ifndef CC
CC = gcc -no-cpp-precomp
GCC = yes
endif

Which later allowed me to run "scan-build make" without issues.

hope that's helpfull.

thanks.


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 16:41:24
Message-ID: 407d949e0908230941x65fc7553t591528c08fca77f2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 23, 2009 at 4:57 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
> I am sure there's plenty of false positives, but I am also quite sure
> there's many real errors on that list.

Do you know how to teach clang about functions which never return?
That seems to be causing most of the false positives because it
doesn't recognize that our error checks stop execution and avoid the
use of the unitialized variables afterwards.

--
greg
http://mit.edu/~gsstark/resume.pdf


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 16:47:46
Message-ID: 3CD58E90-0CD4-4E8E-A3C8-2EF250D9E28F@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 23 Aug 2009, at 17:41, Greg Stark wrote:

> On Sun, Aug 23, 2009 at 4:57 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl
> > wrote:
>> I am sure there's plenty of false positives, but I am also quite sure
>> there's many real errors on that list.
>
> Do you know how to teach clang about functions which never return?
> That seems to be causing most of the false positives because it
> doesn't recognize that our error checks stop execution and avoid the
> use of the unitialized variables afterwards.

I am not the clang developer, so I honestly have no idea how to do it.
But as far as I checked report myself, there's couple 'division by
zero', and 'null reference' errors that looked plausible to someone
as unfamiliar with the postgresql's source as myself.
Like with all static checkers, this one will generate a lot of false
positives, and it is the inevitable cost of using such a tool having
to go through all errors and sieve out positives yourself.

You probably refer to the functions that never return. Sadly, even tho
llvm clang is capable of doing so (one of its strengths is linking
optimization) - the checker is unable to cross reference files, or so
it seems.

Well, like I said - l hope at least part of that report is useful.


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 16:47:49
Message-ID: 20090823164749.GC17121@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 23, 2009 at 05:41:24PM +0100, Greg Stark wrote:
> On Sun, Aug 23, 2009 at 4:57 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
> > I am sure there's plenty of false positives, but I am also quite sure
> > there's many real errors on that list.
>
> Do you know how to teach clang about functions which never return?
> That seems to be causing most of the false positives because it
> doesn't recognize that our error checks stop execution and avoid the
> use of the unitialized variables afterwards.

This caused many of the false positives in Coverity's tool as well.

The way you work around it is by altering the definition of
elog/ereport slightly so that after the usual expansion you add:

if( level >= ERROR) exit(1)

If it were just a matter of a function that didn't return it'd be easy.
What we have is a function that doesn't return depending on the
arguments, this is much trickier.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 16:49:46
Message-ID: 88496B1B-2F70-4F0A-A7FB-91BAF4B7DEB2@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 23 Aug 2009, at 17:41, Greg Stark wrote:
>
> Do you know how to teach clang about functions which never return?

http://clang-analyzer.llvm.org/annotations.html#attr_noreturn


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 17:11:10
Message-ID: 790526BE-108F-48BE-BBD1-54DD4488062C@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

http://zlew.org/postgresql_static_check/scan-build-2009-08-23-5/report-MAVb5D.html#EndPath
for a very positive one - at least from strict language point of view.

consider: float f = 100000000; f++; printf("%f\n", f);


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 17:16:38
Message-ID: 407d949e0908231016v4ea77b97g6e2acfa7f0479423@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 23, 2009 at 6:11 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
> http://zlew.org/postgresql_static_check/scan-build-2009-08-23-5/report-MAVb5D.html#EndPath
> for a very positive one - at least from strict language point of view.
>
> consider: float f = 100000000; f++; printf("%f\n", f);

I believe the maximum value of the numbers involved here is the sample
size which is currently capped at 10,000. But I'm not exactly sure.

--
greg
http://mit.edu/~gsstark/resume.pdf


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 17:20:13
Message-ID: C5AD9CC4-3EEB-4774-8C7F-3B85DCEA3983@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

about the false positives around 'null reference'. I'll try sticking
exit(1)'s at the end of each macro - and see if that makes most of
them go away.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 17:31:06
Message-ID: 28388.1251048666@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> On Sun, Aug 23, 2009 at 6:11 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
>> http://zlew.org/postgresql_static_check/scan-build-2009-08-23-5/report-MAVb5D.html#EndPath
>> for a very positive one - at least from strict language point of view.
>>
>> consider: float f = 100000000; f++; printf("%f\n", f);

> I believe the maximum value of the numbers involved here is the sample
> size which is currently capped at 10,000. But I'm not exactly sure.

No, the maximum value is somewhere around the maximum number of rows in
a table, which is on the rough order of 4e12, which is several orders of
magnitude below the threshold at which counting in a double becomes
inaccurate. It is, however, above the point at which counting in an
int32 will overflow. So the alternative would be to assume that we have
a working int64 data type, which doesn't strike me as an improvement
in the portability of the code.

regards, tom lane


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 18:31:39
Message-ID: CA008398-9850-437E-BC54-C846C1F6AADF@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 19:21:46
Message-ID: 80BF6479-D853-41F9-8272-52D3E5393592@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


this one should contain substantialy less false positives, because
error functions were marked as the 'never exit' points:

http://zlew.org/postgresql_static_check/scan-build-2009-08-23-9/

for the record, here's patch that marks elog, etc as dead ends:

Index: src/include/utils/elog.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/elog.h,v
retrieving revision 1.101
diff -u -b -r1.101 elog.h
--- src/include/utils/elog.h 11 Jun 2009 14:49:13 -0000 1.101
+++ src/include/utils/elog.h 23 Aug 2009 19:20:55 -0000
@@ -112,8 +112,8 @@
#define TEXTDOMAIN NULL

extern bool errstart(int elevel, const char *filename, int lineno,
- const char *funcname, const char *domain);
-extern void errfinish(int dummy,...);
+ const char *funcname, const char *domain)
__attribute__((analyzer_noreturn));
+extern void errfinish(int dummy,...)
__attribute__((analyzer_noreturn));

extern int errcode(int sqlerrcode);

@@ -197,7 +197,7 @@
elog_finish(int elevel, const char *fmt,...)
/* This extension allows gcc to check the format string for
consistency with
the supplied arguments. */
-__attribute__((format(printf, 2, 3)));
+__attribute__((format(printf, 2, 3)))
__attribute__((analyzer_noreturn));

/* Support for attaching context information to error reports */


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 19:31:43
Message-ID: 2968.1251055903@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> writes:
> for the record, here's patch that marks elog, etc as dead ends:

That does not look like the right thing at all, since now the checker
will believe that elog(NOTICE) and such don't return. I think you
need to use Martijn's suggestion instead.

regards, tom lane


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 19:34:27
Message-ID: A48ED43A-05FC-419F-9EBC-4DB48EC55267@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 23 Aug 2009, at 20:31, Tom Lane wrote:

> Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> writes:
>> for the record, here's patch that marks elog, etc as dead ends:
>
> That does not look like the right thing at all, since now the checker
> will believe that elog(NOTICE) and such don't return. I think you
> need to use Martijn's suggestion instead.
>

Still, there are few worrying finds on that list as it is anyway.
I hope you guys will find it useful.

I'll modify macro according to Martijn's suggesion, and rerun it again.
My laptop is pretty slow, so it will be probably another 1-1.5h before
I'll get it.


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 22:16:59
Message-ID: 61BBC425-BD75-4DC9-8BE3-A6570E41D08B@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

ok folks, here's the last one for Today:

http://zlew.org/postgresql_static_check/scan-build-2009-08-23-29/

tar ball with report can be downloaded from here: http://zlew.org/postgresql_static_check/postgresql_static_check_23rdAugust2009.tar.xz
(compressed with lzma's xz tool).

here's the patch for elog stuff:

Index: src/include/utils/elog.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/elog.h,v
retrieving revision 1.101
diff -u -b -r1.101 elog.h
--- src/include/utils/elog.h 11 Jun 2009 14:49:13 -0000 1.101
+++ src/include/utils/elog.h 23 Aug 2009 22:16:05 -0000
@@ -104,7 +104,7 @@
*/
#define ereport_domain(elevel, domain, rest) \
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain) ? \
- (errfinish rest) : (void) 0)
+ (errfinish rest) : (void) 0), (elevel >= ERROR) ? exit(1) : 0

#define ereport(elevel, rest) \
ereport_domain(elevel, TEXTDOMAIN, rest)
@@ -190,7 +190,7 @@
* elog(ERROR, "portal \"%s\" not found", stmt->portalname);
*----------
*/
-#define elog elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO),
elog_finish
+#define elog(A, ...) elog_start(__FILE__, __LINE__,
PG_FUNCNAME_MACRO), elog_finish(A, __VA_ARGS__), (A >= ERROR) ?
exit(1) : 0

extern void elog_start(const char *filename, int lineno, const char
*funcname);
extern void

hopefully satisfying everyone.

Hope to see few fixes out of that ;)

thanks.


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 23:15:43
Message-ID: 407d949e0908231615g5d929d42k83abc4f9ffeb5625@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 23, 2009 at 11:16 PM, Grzegorz
Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
> ok folks, here's the last one for Today:
>
> http://zlew.org/postgresql_static_check/scan-build-2009-08-23-29/

This does look better. The first one I looked at looks like a
legitimate bug. The nice thing is that this seems to be picking up a
lot of error handling cases that we don't bother to have regression
tests for.

One more request though. Can you configure with --enable-assertions so
that it doesn't pick up failures where we have already documented that
the case it's claiming can happen can't happen. Those could possibly
be bugs but they're more likely to be cases where we know that a given
data structure's rep invariant prohibits the combination of states
that it's assuming.

--
greg
http://mit.edu/~gsstark/resume.pdf


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-23 23:42:55
Message-ID: 34A9FFFB-7A60-48E1-A45E-066F61684466@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 24 Aug 2009, at 00:15, Greg Stark wrote:

> On Sun, Aug 23, 2009 at 11:16 PM, Grzegorz
> Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
>> ok folks, here's the last one for Today:
>>
>> http://zlew.org/postgresql_static_check/scan-build-2009-08-23-29/
>
> This does look better. The first one I looked at looks like a
> legitimate bug. The nice thing is that this seems to be picking up a
> lot of error handling cases that we don't bother to have regression
> tests for.
true
>
> One more request though. Can you configure with --enable-assertions so

--enable-cassert, enabled, and also added exit_* in pg_dump to list
of functions that never return.

new report's at: http://zlew.org/postgresql_static_check/scan-build-2009-08-24-2/

the archive is at : http://zlew.org/postgresql_static_check/postgresql_static_check_24thAugust2009.tar.xz

So that the overall 'static check' patch now looks like this:

Index: src/bin/pg_dump/pg_backup.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v
retrieving revision 1.52
diff -u -b -r1.52 pg_backup.h
--- src/bin/pg_dump/pg_backup.h 11 Jun 2009 14:49:07 -0000 1.52
+++ src/bin/pg_dump/pg_backup.h 23 Aug 2009 23:31:43 -0000
@@ -150,7 +150,7 @@

extern void
exit_horribly(Archive *AH, const char *modulename, const char
*fmt,...)
-__attribute__((format(printf, 3, 4)));
+__attribute__((format(printf, 3, 4)))
__attribute__((analyzer_noreturn));

/* Lets the archive know we have a DB connection to shutdown if it
dies */
Index: src/bin/pg_dump/pg_dump.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.h,v
retrieving revision 1.156
diff -u -b -r1.156 pg_dump.h
--- src/bin/pg_dump/pg_dump.h 2 Aug 2009 22:14:52 -0000 1.156
+++ src/bin/pg_dump/pg_dump.h 23 Aug 2009 23:31:43 -0000
@@ -481,7 +481,7 @@
extern void *pg_realloc(void *ptr, size_t size);

extern void check_conn_and_db(void);
-extern void exit_nicely(void);
+extern void exit_nicely(void) __attribute__((analyzer_noreturn));

extern void parseOidArray(const char *str, Oid *array, int arraysize);

Index: src/include/postgres.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/postgres.h,v
retrieving revision 1.92
diff -u -b -r1.92 postgres.h
--- src/include/postgres.h 1 Jan 2009 17:23:55 -0000 1.92
+++ src/include/postgres.h 23 Aug 2009 23:31:43 -0000
@@ -691,6 +691,6 @@

extern int ExceptionalCondition(const char *conditionName,
const char *errorType,
- const char *fileName, int lineNumber);
+ const char *fileName, int lineNumber)
__attribute__((analyzer_noreturn));

#endif /* POSTGRES_H */
Index: src/include/utils/elog.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/elog.h,v
retrieving revision 1.101
diff -u -b -r1.101 elog.h
--- src/include/utils/elog.h 11 Jun 2009 14:49:13 -0000 1.101
+++ src/include/utils/elog.h 23 Aug 2009 23:31:43 -0000
@@ -104,7 +104,7 @@
*/
#define ereport_domain(elevel, domain, rest) \
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain) ? \
- (errfinish rest) : (void) 0)
+ (errfinish rest) : (void) 0), (elevel >= ERROR) ? exit(1) : 0

#define ereport(elevel, rest) \
ereport_domain(elevel, TEXTDOMAIN, rest)
@@ -190,7 +190,7 @@
* elog(ERROR, "portal \"%s\" not found", stmt->portalname);
*----------
*/
-#define elog elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO),
elog_finish
+#define elog(A, ...) elog_start(__FILE__, __LINE__,
PG_FUNCNAME_MACRO), elog_finish(A, __VA_ARGS__), (A >= ERROR) ?
exit(1) : 0

extern void elog_start(const char *filename, int lineno, const char
*funcname);

That's it folks for Today, gotta go to sleep.
Have fun...


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-24 13:40:47
Message-ID: 1251121247.10096.19.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On mån, 2009-08-24 at 00:42 +0100, Grzegorz Jaskiewicz wrote:
> --enable-cassert, enabled, and also added exit_* in pg_dump to list
> of functions that never return.

A few more functions to mark noreturn: DateTimeParseError(), and
die_horribly() in pg_dump


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-27 11:57:06
Message-ID: 75F43AD6-F88E-4F92-87F5-D3E12676E417@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 24 Aug 2009, at 14:40, Peter Eisentraut wrote:

> On mån, 2009-08-24 at 00:42 +0100, Grzegorz Jaskiewicz wrote:
>> --enable-cassert, enabled, and also added exit_* in pg_dump to list
>> of functions that never return.
>
> A few more functions to mark noreturn: DateTimeParseError(), and
> die_horribly() in pg_dump

done.

new scan at: http://zlew.org/postgresql_static_check/scan-build-2009-08-27-2/
archive at: http://zlew.org/postgresql_static_check/postgresql_static_check_27thAugust2009.tar.xz

If people find it useful (altho, I've only seen single commit as
result of that checker, and nothing fancy either) - I can write a
script that would update it on daily basis.

what you people say ?

New Patch :

Index: src/Makefile.global.in
===================================================================
RCS file: /projects/cvsroot/pgsql/src/Makefile.global.in,v
retrieving revision 1.258
diff -u -b -r1.258 Makefile.global.in
--- src/Makefile.global.in 26 Aug 2009 22:24:42 -0000 1.258
+++ src/Makefile.global.in 27 Aug 2009 11:54:36 -0000
@@ -205,7 +205,10 @@
endif
endif # not PGXS

+ifndef CC
CC = @CC@
+endif
+
GCC = @GCC@
SUN_STUDIO_CC = @SUN_STUDIO_CC@
CFLAGS = @CFLAGS@
Index: src/bin/pg_dump/pg_backup.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v
retrieving revision 1.52
diff -u -b -r1.52 pg_backup.h
--- src/bin/pg_dump/pg_backup.h 11 Jun 2009 14:49:07 -0000 1.52
+++ src/bin/pg_dump/pg_backup.h 27 Aug 2009 11:54:37 -0000
@@ -150,7 +150,7 @@

extern void
exit_horribly(Archive *AH, const char *modulename, const char
*fmt,...)
-__attribute__((format(printf, 3, 4)));
+__attribute__((format(printf, 3, 4))) __attribute__
((analyzer_noreturn));

/* Lets the archive know we have a DB connection to shutdown if it
dies */
Index: src/bin/pg_dump/pg_backup_archiver.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v
retrieving revision 1.82
diff -u -b -r1.82 pg_backup_archiver.h
--- src/bin/pg_dump/pg_backup_archiver.h 7 Aug 2009 22:48:34 -0000 1.82
+++ src/bin/pg_dump/pg_backup_archiver.h 27 Aug 2009 11:54:37 -0000
@@ -325,7 +325,7 @@
/* Used everywhere */
extern const char *progname;

-extern void die_horribly(ArchiveHandle *AH, const char *modulename,
const char *fmt,...) __attribute__((format(printf, 3, 4)));
+extern void die_horribly(ArchiveHandle *AH, const char *modulename,
const char *fmt,...) __attribute__((format(printf, 3, 4)))
__attribute__((analyzer_noreturn));
extern void warn_or_die_horribly(ArchiveHandle *AH, const char
*modulename, const char *fmt,...) __attribute__((format(printf, 3, 4)));
extern void write_msg(const char *modulename, const char *fmt,...)
__attribute__((format(printf, 2, 3)));

Index: src/bin/pg_dump/pg_dump.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.h,v
retrieving revision 1.156
diff -u -b -r1.156 pg_dump.h
--- src/bin/pg_dump/pg_dump.h 2 Aug 2009 22:14:52 -0000 1.156
+++ src/bin/pg_dump/pg_dump.h 27 Aug 2009 11:54:37 -0000
@@ -481,7 +481,7 @@
extern void *pg_realloc(void *ptr, size_t size);

extern void check_conn_and_db(void);
-extern void exit_nicely(void);
+extern void exit_nicely(void) __attribute__((analyzer_noreturn));

extern void parseOidArray(const char *str, Oid *array, int arraysize);

Index: src/include/postgres.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/postgres.h,v
retrieving revision 1.92
diff -u -b -r1.92 postgres.h
--- src/include/postgres.h 1 Jan 2009 17:23:55 -0000 1.92
+++ src/include/postgres.h 27 Aug 2009 11:54:37 -0000
@@ -691,6 +691,6 @@

extern int ExceptionalCondition(const char *conditionName,
const char *errorType,
- const char *fileName, int lineNumber);
+ const char *fileName, int lineNumber) __attribute__
((analyzer_noreturn));

#endif /* POSTGRES_H */
Index: src/include/utils/datetime.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/datetime.h,v
retrieving revision 1.75
diff -u -b -r1.75 datetime.h
--- src/include/utils/datetime.h 11 Jun 2009 14:49:13 -0000 1.75
+++ src/include/utils/datetime.h 27 Aug 2009 11:54:37 -0000
@@ -300,7 +300,7 @@
int *dtype, struct pg_tm * tm, fsec_t *fsec);

extern void DateTimeParseError(int dterr, const char *str,
- const char *datatype);
+ const char *datatype) __attribute__((__noreturn__));

extern int DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp);

Index: src/include/utils/elog.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/elog.h,v
retrieving revision 1.101
diff -u -b -r1.101 elog.h
--- src/include/utils/elog.h 11 Jun 2009 14:49:13 -0000 1.101
+++ src/include/utils/elog.h 27 Aug 2009 11:54:37 -0000
@@ -104,7 +104,7 @@
*/
#define ereport_domain(elevel, domain, rest) \
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain) ? \
- (errfinish rest) : (void) 0)
+ (errfinish rest) : (void) 0), (elevel >= ERROR) ? exit(1) : 0

#define ereport(elevel, rest) \
ereport_domain(elevel, TEXTDOMAIN, rest)
@@ -190,7 +190,7 @@
* elog(ERROR, "portal \"%s\" not found", stmt->portalname);
*----------
*/
-#define elog elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO),
elog_finish
+#define elog(A, ...) elog_start(__FILE__, __LINE__,
PG_FUNCNAME_MACRO), elog_finish(A, __VA_ARGS__), (A >= ERROR) ? exit
(1) : 0

extern void elog_start(const char *filename, int lineno, const char
*funcname);
extern void


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Greg Stark <gsstark(at)mit(dot)edu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-27 12:39:46
Message-ID: DAA43615-E02A-42A0-8A75-0363C0069A42@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

heh, sorry folks for the noise again :/

There was a fair amount of false positives there - due to nature of
Assert() macro. Mainly, since assert_enabled is a runtime variable,
not a macro (which I sadly overlooked).

So, hardcoding it to (1) (using CPP) removed quite few false positives.

New results at:

http://zlew.org/postgresql_static_check/scan-build-2009-08-27-4/
archive at: http://zlew.org/postgresql_static_check/postgresql_static_check_27thAugust2009_2.tar.xz

Please tell me, if you think that it can be improved more.


From: Alex Hunsaker <badalex(at)gmail(dot)com>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Greg Stark <gsstark(at)mit(dot)edu>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-27 17:41:05
Message-ID: 34d269d40908271041q56667b98jb8500aa12a61eb14@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Aug 27, 2009 at 06:39, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
> heh, sorry folks for the noise again :/
>
> There was a fair amount of false positives there - due to nature of Assert()
> macro. Mainly, since assert_enabled is a runtime variable, not a macro
> (which I sadly overlooked).
>
> So, hardcoding it to (1) (using CPP) removed quite few false positives.
>
> New results at:
>
> http://zlew.org/postgresql_static_check/scan-build-2009-08-27-4/
> archive at:
> http://zlew.org/postgresql_static_check/postgresql_static_check_27thAugust2009_2.tar.xz
>
> Please tell me, if you think that it can be improved more.

Looks like your still missing ExitPostmaster(1) see
http://zlew.org/postgresql_static_check/scan-build-2009-08-27-4/report-iqR9gz.html#EndPath.

and maybe ereport(ERROR) ?

see http://zlew.org/postgresql_static_check/scan-build-2009-08-27-4/report-gkkK9S.html#EndPath
it calls report_untranslatable_char() which in turn calls ereport(ERROR)
(do you have to mark every function that calls ereport(ERROR) as one
that exits?)

:)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alex Hunsaker <badalex(at)gmail(dot)com>
Cc: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-27 17:59:01
Message-ID: 17135.1251395941@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alex Hunsaker <badalex(at)gmail(dot)com> writes:
> (do you have to mark every function that calls ereport(ERROR) as one
> that exits?)

That would be an open-ended project, and probably in many cases wouldn't
change the clang report anyway. I think it's only worth worrying about
the ones that we find will suppress some false positives.

regards, tom lane


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alex Hunsaker <badalex(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Greg Stark <gsstark(at)mit(dot)edu>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-29 16:13:50
Message-ID: A3BC156E-37F5-48D7-B30B-1DEBF6D5ABA0@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


new one at http://zlew.org/postgresql_static_check/scan-build-2009-08-29-3/
archive at : http://zlew.org/postgresql_static_check/postgresql_static_check_29thAugust2009.tar.xz

as always, comments are welcomed. And constructive explanation of any
wrong-results will be relayed to clang-checker developer(s).

hth.


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-29 16:35:35
Message-ID: 407d949e0908290935j19167061oa83776b00a264304@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

We still have things like this showing "division by zero":

Assert(activeTapes > 0);
1913 slotsPerTape = (state->memtupsize - state->mergefirstfree) / activeTapes;

It looks like if you marked ExceptionalCondition() as never returning
then it should hide this.

--
greg
http://mit.edu/~gsstark/resume.pdf


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-29 16:47:42
Message-ID: 19454D21-D033-4F9B-8EE5-62F6729F6348@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 29 Aug 2009, at 17:35, Greg Stark wrote:

> We still have things like this showing "division by zero":
>
> Assert(activeTapes > 0);
> 1913 slotsPerTape = (state->memtupsize - state->mergefirstfree) /
> activeTapes;
>
>
> It looks like if you marked ExceptionalCondition() as never returning
> then it should hide this.
well, it is marked as such , here's excerpt from differences to head:

extern int ExceptionalCondition(const char *conditionName,
const char *errorType,
- const char *fileName, int
lineNumber);
+ const char *fileName, int
lineNumber) __attribute__((analyzer_noreturn));


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-29 17:05:00
Message-ID: 407d949e0908291005y6481a5d4xe0cd19e2f741d993@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Oh, I think I see what's happening. Our assertions can still be turned
off at run-time with the variable assert_enabled.

Hm, you would have to replace assert_enabled with a #define in
postgres.h and then do something about the guc.c code which assigns to
it.

On another note is there any way to marke MemoryContextAlloc,
MemoryContextAllocZero, palloc, repalloc, and friends as never
returning NULL? I think that's causing most of the "null dereferenced"
errors.


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 11:21:04
Message-ID: 2A66594A-E5A0-47DE-A41C-5EB41E1147EC@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 29 Aug 2009, at 18:05, Greg Stark wrote:

> Oh, I think I see what's happening. Our assertions can still be turned
> off at run-time with the variable assert_enabled.

Index: src/include/postgres.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/postgres.h,v
retrieving revision 1.92
diff -b -u -r1.92 postgres.h
--- src/include/postgres.h 1 Jan 2009 17:23:55 -0000 1.92
+++ src/include/postgres.h 30 Aug 2009 11:17:50 -0000
@@ -639,6 +639,7 @@
*/

extern PGDLLIMPORT bool assert_enabled;
+#define assert_enabled (1)

/*
* USE_ASSERT_CHECKING, if defined, turns on all the assertions.
@@ -666,7 +667,7 @@
* Isn't CPP fun?
*/
#define TrapMacro(condition, errorType) \
- ((bool) ((! assert_enabled) || ! (condition) || \
+ ((bool) ( ! (condition) || \
(ExceptionalCondition(CppAsString(condition), (errorType), \
__FILE__, __LINE__))))

@@ -689,8 +690,10 @@
Trap(!(condition), "BadState")
#endif /* USE_ASSERT_CHECKING */

+#undef assert_enabled
+
extern int ExceptionalCondition(const char *conditionName,
const char *errorType,
- const char *fileName, int lineNumber);
+ const char *fileName, int lineNumber) __attribute__
((analyzer_noreturn));

like that ?
This is another excerpt from my local mods, that I use before running
clang-checker over it.

but looking at Assert() macros in code (it expands macros if you
hoover mouse pointer over one) - it still keeps 'assert_enabled'
literal there. damn...


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 13:26:32
Message-ID: 73F7F583-473F-4F83-9193-F2119C1EDE65@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

okay, I think I nailed the assert part right. (3rd iteration, about
time...).
as usual: http://zlew.org/postgresql_static_check/scan-build-2009-08-30-2/

archive one dir up.

the current patch attached.

Attachment Content-Type Size
postgres_checker_patch.patch.bz2 application/x-bzip2 2.1 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 14:26:39
Message-ID: 1251642399.22097.0.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On lör, 2009-08-29 at 17:35 +0100, Greg Stark wrote:
> We still have things like this showing "division by zero":
>
> Assert(activeTapes > 0);
> 1913 slotsPerTape = (state->memtupsize - state->mergefirstfree) / activeTapes;
>
>
> It looks like if you marked ExceptionalCondition() as never returning
> then it should hide this.

Well, if you can disable the assertion, then there is still a possible
bug here, no?


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 14:40:16
Message-ID: 407d949e0908300740v35c3536auf36cdc8c3431c9d4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 30, 2009 at 3:26 PM, Peter Eisentraut<peter_e(at)gmx(dot)net> wrote:
> On lör, 2009-08-29 at 17:35 +0100, Greg Stark wrote:
>> We still have things like this showing "division by zero":
>>
>> Assert(activeTapes > 0);
>> 1913          slotsPerTape = (state->memtupsize - state->mergefirstfree) / activeTapes;
>>
>>
>> It looks like if you marked ExceptionalCondition() as never returning
>> then it should hide this.
>
> Well, if you can disable the assertion, then there is still a possible
> bug here, no?

Yeah, the problem is that clang doesn't know our rep invariants and
inter-procedure call signature guarantees. Ie, activeTapes here is
initialized to the count of tapes in the tuplesort state when a merge
begins. Clang doesn't know that we never call beginmerge on a
tuplesort that has no active tapes.

So going on the assumption that our Asserts indicate somebody actually
thought about the case they cover and checked that it's a reasonable
assumption... then we don't need clang to tell us about them.

I think most of the remaining false positives are cases where palloc,
palloc0, repalloc, MemoryContextAlloc, or MemoryContextAllocZero
return values are deferenced. Clang doesn't know that these functions
never return NULL so it's marking every case as a possible NULL
dereference.

--
greg
http://mit.edu/~gsstark/resume.pdf


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 14:46:24
Message-ID: 407d949e0908300746t16769d52nf102953cd0a41eee@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

So three of the four dead initialization warnings are legitimate -- if
minor -- errors. Attached is a patch to remove the redundant
initializations.

--
greg
http://mit.edu/~gsstark/resume.pdf

Attachment Content-Type Size
clang-dead-initializations.patch text/x-patch 1.1 KB

From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 14:57:22
Message-ID: 85B187C6-93F2-4051-BEB4-884630926DCF@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 30 Aug 2009, at 15:46, Greg Stark wrote:

> So three of the four dead initialization warnings are legitimate -- if
> minor -- errors. Attached is a patch to remove the redundant
> initializations.

well, all I can do is this: http://llvm.org/bugs/show_bug.cgi?id=4832

I find it hard to belive tho, that it only found 4 possible positives ;)


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 15:10:49
Message-ID: 407d949e0908300810g524ed757sea76163839024e33@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 30, 2009 at 3:57 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
>
> On 30 Aug 2009, at 15:46, Greg Stark wrote:
>
>> So three of the four dead initialization warnings are legitimate -- if
>> minor -- errors. Attached is a patch to remove the redundant
>> initializations.
>
>
> well, all I can do is this: http://llvm.org/bugs/show_bug.cgi?id=4832
>
> I find it hard to belive tho, that it only found 4 possible positives ;)

You might try something like the attached.

--
greg
http://mit.edu/~gsstark/resume.pdf

Attachment Content-Type Size
clang-palloc-nonulls.patch text/x-patch 1.5 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 16:29:16
Message-ID: 13898.1251649756@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> I think most of the remaining false positives are cases where palloc,
> palloc0, repalloc, MemoryContextAlloc, or MemoryContextAllocZero
> return values are deferenced. Clang doesn't know that these functions
> never return NULL so it's marking every case as a possible NULL
> dereference.

If clang assumes that every function that returns a pointer could return
NULL, then we are going to have many many many many false positives
at levels far removed from palloc. I'd almost suggest that we look for
a way to reverse its default assumption about that. Failing that,
I fear we shall simply have to ignore that particular message as
uselessly noisy.

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 16:54:19
Message-ID: 16314.1251651259@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> So three of the four dead initialization warnings are legitimate -- if
> minor -- errors. Attached is a patch to remove the redundant
> initializations.

Applied, thanks.

regards, tom lane


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 16:58:50
Message-ID: 9B6056D3-C430-4802-BABB-FBBBABD36079@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

with Greg's suggested palloc and friends patch: http://zlew.org/postgresql_static_check/scan-build-2009-08-30-3


From: Greg Stark <gsstark(at)mit(dot)edu>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 17:07:51
Message-ID: 407d949e0908301007h1f5d017h96fadcb46ba0cdbb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 30, 2009 at 5:58 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl> wrote:
> with Greg's suggested palloc and friends patch:
> http://zlew.org/postgresql_static_check/scan-build-2009-08-30-3

Argh. That didn't help at all. hm, I suppose instead of (exit(1),NULL)
we could just put ((void*)1) there?

But I think Tom's right. Worse, I think until it can do
inter-procedural analysis these messages will always be nearly all
false positives. Many if not most of our functions take pointers or
data structures which contain pointers as arguments or return values.
Most of the time those arguments and return values cannot contain NULL
pointers and the code doesn't bother to check that every single time.

--
greg
http://mit.edu/~gsstark/resume.pdf


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 17:09:39
Message-ID: 8E6FD914-9F55-405B-800A-C1E212480F93@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 30 Aug 2009, at 18:07, Greg Stark wrote:

> On Sun, Aug 30, 2009 at 5:58 PM, Grzegorz Jaskiewicz<gj(at)pointblue(dot)com(dot)pl
> > wrote:
>> with Greg's suggested palloc and friends patch:
>> http://zlew.org/postgresql_static_check/scan-build-2009-08-30-3
>
> Argh. That didn't help at all. hm, I suppose instead of (exit(1),NULL)
> we could just put ((void*)1) there?
>
> But I think Tom's right. Worse, I think until it can do
> inter-procedural analysis these messages will always be nearly all
> false positives. Many if not most of our functions take pointers or
> data structures which contain pointers as arguments or return values.
> Most of the time those arguments and return values cannot contain NULL
> pointers and the code doesn't bother to check that every single time.

sure, I can try.
Btw, I got response to my bug from llvm devs, and they fully agree on
all that.


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 17:54:52
Message-ID: 2EDEEB18-5C73-421C-934D-09B78A63F1BB@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 17:56:29
Message-ID: 430D69A6-43C8-4494-80C8-7BAD1DB39191@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 18:14:00
Message-ID: 17988.1251656040@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> writes:
> please don't tell me that this is bogus: http://zlew.org/postgresql_static_check/scan-build-2009-08-30-4/report-7JaICX.html#EndPath

Yes, it's bogus. ctid is never passed as NULL. It might point at
an "invalid" itempointer (one with ip_posid == 0). Look at the only
call site.

This seems to indicate that clang is stupider than I would have hoped.
Isn't it capable of doing the same types of analysis that gcc does
when inlining?

regards, tom lane


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 18:28:21
Message-ID: 528AEEBB-3179-4F1B-8A8C-895FE2316166@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 30 Aug 2009, at 19:14, Tom Lane wrote:

> Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> writes:
>> please don't tell me that this is bogus: http://zlew.org/postgresql_static_check/scan-build-2009-08-30-4/report-7JaICX.html#EndPath
>
> Yes, it's bogus. ctid is never passed as NULL. It might point at
> an "invalid" itempointer (one with ip_posid == 0). Look at the only
> call site.

so why do we check if the pointer is valid ?

>
> This seems to indicate that clang is stupider than I would have hoped.
> Isn't it capable of doing the same types of analysis that gcc does
> when inlining?

well, it is usable, but that doesn't mean complete. That's why I am
trying to work both ways to provide some info to clang-checker devs,
and you guys - with the reports it generates.
on the side note, xcode in snow leopard uses it under the hood to do
'build & analyze', and it helped me to locate few potential issues in
my iphone code. Now, of course my code is times less complicated than
postgresql's, but still - it is potentially useful.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-08-30 18:33:47
Message-ID: 18257.1251657227@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> writes:
> On 30 Aug 2009, at 19:14, Tom Lane wrote:
>> Yes, it's bogus. ctid is never passed as NULL. It might point at
>> an "invalid" itempointer (one with ip_posid == 0). Look at the only
>> call site.

> so why do we check if the pointer is valid ?

[ shrug... ] The macro is more general than is necessary in this
specific context. In an actual build I'd expect the compiler to figure
out that the null-pointer test is redundant and optimize it away, since
after inlining it would see that ctid is the address of a local variable.

regards, tom lane


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-09-02 20:27:54
Message-ID: 32AFC801-D2B7-47B1-B003-924E9A755D2A@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

new report: http://zlew.org/postgresql_static_check/scan-build-2009-09-02-1/

archive one dir up, as usual (with index of all previous reports).


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-09-02 20:38:15
Message-ID: 20090902203815.GF5314@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Grzegorz Jaskiewicz escribió:
> new report: http://zlew.org/postgresql_static_check/scan-build-2009-09-02-1/
>
> archive one dir up, as usual (with index of all previous reports).

What's with the "analyzer failures"? Did you submit bug reports about
them?

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-09-02 20:46:30
Message-ID: 9BC1BA01-EAB1-4B69-83FE-7F71FA2080C3@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 2 Sep 2009, at 21:38, Alvaro Herrera wrote:

> Grzegorz Jaskiewicz escribió:
>> new report: http://zlew.org/postgresql_static_check/scan-build-2009-09-02-1/
>>
>> archive one dir up, as usual (with index of all previous reports).
>
> What's with the "analyzer failures"? Did you submit bug reports about
> them?

honestly, why would you even ask me such a question....

My currently open bugs:

http://llvm.org/bugs/show_bug.cgi?id=4867
http://llvm.org/bugs/show_bug.cgi?id=4832


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-09-04 20:29:42
Message-ID: 63D30B0B-AF5A-444D-A992-8439CE297234@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

clang developers were quick to iron out their bugs, here's Today report:

http://zlew.org/postgresql_static_check/scan-build-2009-09-04-1/


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-09-12 12:06:17
Message-ID: B75BDEB9-41A8-437B-8D28-5A2AE46F225C@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

usual round of updates to the scan report.
Today's report available at:

http://zlew.org/postgresql_static_check/scan-build-2009-09-12-1/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: clang's static checker report.
Date: 2009-09-14 05:04:05
Message-ID: 1289.1252904645@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> writes:
> usual round of updates to the scan report.
> Today's report available at:

> http://zlew.org/postgresql_static_check/scan-build-2009-09-12-1/

Looks like the clang guys still have some work to do. The
null-dereference reports, in particular, seem to be willing to make
self-contradictory assumptions in order to claim there is a possibility
of a null dereference. The clearest example I found was this one:
http://zlew.org/postgresql_static_check/scan-build-2009-09-12-1/report-Ybdv3J.html#EndPath
where to conclude that lp might be null, clang first assumes
PageGetMaxOffsetNumber(page) < offnum (at line 4251); but it then
must assume that that is *false* in order to suppose that control
can arrive at the dereference inside ItemIdIsNormal at line 4254.

regards, tom lane


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: clang's static checker report.
Date: 2009-09-14 17:39:11
Message-ID: 803D4529-6A31-4473-87B6-F261DB1BBCE1@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 14 Sep 2009, at 06:04, Tom Lane wrote:
> Looks like the clang guys still have some work to do.

Thanks Tom, reported to clang dev's .

meanwhile, since quite a lot stuff went in over weekend, and since
Yesterday, new report at:

http://zlew.org/postgresql_static_check/scan-build-2009-09-14-1/


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-09-15 08:51:57
Message-ID: 018C3AFC-EE0B-4242-A85E-A85FF5372233@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>
http://llvm.org/bugs/show_bug.cgi?id=4979

will see, one issue is already fixed. I'll retry when the second one
is too.
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: clang's static checker report.
Date: 2009-09-15 10:06:01
Message-ID: 20090915100601.GA21238@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 14, 2009 at 06:39:11PM +0100, Grzegorz Jaskiewicz wrote:
> meanwhile, since quite a lot stuff went in over weekend, and since
> Yesterday, new report at:
>
> http://zlew.org/postgresql_static_check/scan-build-2009-09-14-1/

Looking at
http://zlew.org/postgresql_static_check/scan-build-2009-09-14-1/report-3LPmKK.html#EndPath
it tells me that the value stored to 'counter' is never used. However, the
"counter++" is called inside a loop and thus will be read the next time the
loop is run.

Looks to me like a bug, or did I miss something?

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!


From: Nicolas Barbier <nicolas(dot)barbier(at)gmail(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: clang's static checker report.
Date: 2009-09-15 11:20:16
Message-ID: b0f3f5a10909150420p3e60e4cap96386cfd7be430a0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2009/9/15 Michael Meskes <meskes(at)postgresql(dot)org>:

> Looking at
> http://zlew.org/postgresql_static_check/scan-build-2009-09-14-1/report-3LPmKK.html#EndPath
> it tells me that the value stored to 'counter' is never used. However, the
> "counter++" is called inside a loop and thus will be read the next time the
> loop is run.
>
> Looks to me like a bug, or did I miss something?

I guess that the problem is that the variable "counter" is declared
inside that loop itself.

Nicolas


From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: clang's static checker report.
Date: 2009-10-03 06:27:31
Message-ID: C1E59F94-72E8-4776-8904-E5F53ECEF051@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

new version under:
http://zlew.org/postgresql_static_check/scan-build-2009-10-03-1/

What's strange, is the increase of 48.2 percent in reports, that
happened about two weeks before (weekend before the previous one).

enjoy.