public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Compile Time Memory Leak Analyses
@ 2001-07-16  5:52 Kevin Atkinson
  2001-07-16  6:13 ` Tim Hollebeek
  2001-07-16 12:21 ` Joern Rennecke
  0 siblings, 2 replies; 19+ messages in thread
From: Kevin Atkinson @ 2001-07-16  5:52 UTC (permalink / raw)
  To: gcc

I was wondering if anyone has given the following idea any thought:

Provide a method of tagging functions (perhaps automatically) on the
memory behavior of there parameters and what they return.  That is tagging
each parameter which is a pointer as either unconditionally freeing a
pointer passed in, conditionally freeing a pointer, or never freeing a
pointer.  And tagging the pointer returned as always needing to be freed,
sometimes needing to be freed, or never needing to be freed.

This information can then be used to detect simple memory problems by
performing flow analyses on a pointer and determine if:
1) A pointer is never freed when should be
2) An already deleted pointer is freed
3) A pointer is freed that shouldn't be

Of course when functions are used that are in the "conditional" class, or
a pointer is copied around several times and it is not possible to
determine if it all of them go out of scope before the data pointed to by
them is freed.  However, it will get a good deal of the simpler cases and
can help a lot of people out by detecting the obvious memory problems.

A similar analyses can be used when a garbage collector is used to
automatically delete blocks of memory when it can be determined that all
pointers pointing to by that memory goes out of scope.  This has the
potential to greatly red using memory usage.

I am not saying that it will be easy (especially the part of the automatic
tagging) however I defiantly think it is possible and would greatly reduce
memory problems in some programs.

---
Kevin Atkinson
kevina at users sourceforge net
http://www.ibiblio.org/kevina/

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: Uninitialized warnings
@ 2001-07-18  9:55 dewar
  2001-07-18 17:11 ` Richard Henderson
  0 siblings, 1 reply; 19+ messages in thread
From: dewar @ 2001-07-18  9:55 UTC (permalink / raw)
  To: dnovillo, shebs; +Cc: amylaar, carlo, dalej, gcc, jbuck, kevina

One request I have, and please ignore it if it has already been discussed,
is that the uninitialized variable warning is currently very uninformative,
since it does not indicate the site at which the uninitialized reference
may occur, and sometimes it takes a big effort to determine why the warning
is being issued. Is this information that can be provided?

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: Uninitialized warnings
@ 2001-07-17 20:03 dewar
  0 siblings, 0 replies; 19+ messages in thread
From: dewar @ 2001-07-17 20:03 UTC (permalink / raw)
  To: carlo, dalej; +Cc: amylaar, gcc, jbuck, kevina

<<Believe it or not, I agree with you, but I'm definitely in a small
minority (1?) around here.  Is there a consensus on how the
uninitialized-variable check should behave?
>>

A bug that is found by examining a warning at compile time represents a huge
cost savings over having to find this same bug during unit testing, system
integration testing, or worse, not finding it at all and having it cause
damage after deployment.

That means to me that one is willing to tolerate quite a few false positives
to find one real bug at compile time.

I do agree that you need a way to selectively turn off warnings so that
sources can be kept clean.

A specific case in point is that when we first ran the GNAT sources through
GCC 3.x, we got about 60 warnings about possibly uninitialized variables.
Six of these were definite bugs, and one of them was a potentially serious
bug. Going through those 60 warnings to find that potentially serious bug
*before* it caused someone trouble was *well* worth the effort.

^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: Uninitialized warnings
@ 2001-07-17 19:55 dewar
  0 siblings, 0 replies; 19+ messages in thread
From: dewar @ 2001-07-17 19:55 UTC (permalink / raw)
  To: carlo, dalej; +Cc: amylaar, gcc, jbuck, kevina

<<Please don't add any warning that can generate false positives.
I'd rather have no warning at all for 100 actual bugs than
100 correct warnings and a false positive.  The reason for
that is that I always use -Werror: I want gcc to abort when
a warning is generated.  The reason for THAT is that a warning
always means that something *is* wrong and will (likely) cause
a runtime error.
>>

I strongly disagree with this point of view. Any warning by its nature
may have false positives, you are after all dealing with legal code with
a well defined meaning, you are just guessing that it is not the intended
meaning, but you cannot be sure your guess is correct.

Obviously you don't want too many false positives, but the 100-1 suggestion
here is way off the reasonable compromise point.

<<If I'd have to suggest an alternative/compromise, then I'd say:
make it possible to temporally turn off a specific warning in
the source code.
>>

In GNAT, we have added pragma Warnings (On | Off); to handle this problem
when it occasionally arises, since it is a requirement of the GNAT build
that no warnings are generated

^ permalink raw reply	[flat|nested] 19+ messages in thread
* uninitialized warnings
@ 1998-02-17 14:10 Jeffrey A Law
  0 siblings, 0 replies; 19+ messages in thread
From: Jeffrey A Law @ 1998-02-17 14:10 UTC (permalink / raw)
  To: egcs

I'd recommend we hold off just a little while fixing these -- I
want to look into fixing the compiler to produce fewer false
positives.



jeff

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2001-07-18 17:11 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-16  5:52 Compile Time Memory Leak Analyses Kevin Atkinson
2001-07-16  6:13 ` Tim Hollebeek
2001-07-16 11:26   ` Kevin Atkinson
2001-07-16 12:21 ` Joern Rennecke
2001-07-16 15:38   ` Joe Buck
2001-07-16 18:04     ` Joern Rennecke
2001-07-16 20:20       ` Kevin Atkinson
2001-07-17  9:51         ` Uninitialized warnings Dale Johannesen
2001-07-17 15:33           ` Carlo Wood
2001-07-17 16:02             ` Dale Johannesen
2001-07-18  6:24             ` Stan Shebs
2001-07-18  6:40               ` Diego Novillo
2001-07-17  9:06       ` Compile Time Memory Leak Analyses Joe Buck
2001-07-17 11:44         ` J.T. Conklin
  -- strict thread matches above, loose matches on Subject: below --
2001-07-18  9:55 Uninitialized warnings dewar
2001-07-18 17:11 ` Richard Henderson
2001-07-17 20:03 dewar
2001-07-17 19:55 dewar
1998-02-17 14:10 uninitialized warnings Jeffrey A Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).