public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Using alloca in function parameters buggy or works ???
@ 2004-09-16 15:41 Kaveh R. Ghazi
  2004-09-16 15:52 ` Jeffrey A Law
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Kaveh R. Ghazi @ 2004-09-16 15:41 UTC (permalink / raw)
  To: gcc

I'm looking over some memory leaks in gcc and I'm seeing lots of funny
uses of concat like this from gcc.c:is_directory()

    strcmp (path,
            concat (dir_separator_str, "lib", dir_separator_str, ".", NULL))

It's pretty clear this memory allocation never gets free'd.  I'd like
to replace stuff like this with ACONCAT from libiberty which uses
alloca and thus doesn't leak.

Normally people don't like alloca I assume because if the backup
libiberty C_alloca is used (which uses malloc underneath the hood),
sometimes stuff isn't free'd because we don't call alloca(0) anywhere.
Then memory use balloons in some edge cases.

However we're already leaking here so if it was a "balloon" case we'd
already know about it. :-)

I'd like to make as little code change as possible for these cases,
which means putting the ACONCAT use (and thus a call to alloca) right
in there as a function call parameter.

My question is that I seem to recall passing the result of alloca
immediately as a function parameter was buggy at some point in GCC.
Using such a version might trigger a bootstrap failure if that buggy
GCC is used in stage1.

So I'm wondering:

1.  Was this bug in any released version of GCC that we care about?
2.  Does my example above trigger the bug?
3.  Any simple workaround?  (Other than don't do that.)

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu

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

end of thread, other threads:[~2004-09-19 11:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-16 15:41 Using alloca in function parameters buggy or works ??? Kaveh R. Ghazi
2004-09-16 15:52 ` Jeffrey A Law
2004-09-16 16:08   ` Graham Stott
2004-09-16 16:23 ` Dave Korn
2004-09-16 16:38   ` Robert Dewar
2004-09-19 14:02     ` Marc Espie
2004-09-16 16:31 ` Andreas Schwab
2004-09-16 16:35   ` Jeffrey A Law
2004-09-16 16:36     ` Dave Korn
2004-09-16 16:43       ` Graham Stott
2004-09-16 17:42         ` Dave Korn
2004-09-16 16:53       ` Andreas Schwab
2004-09-16 16:51 ` DJ Delorie
2004-09-16 17:32   ` Kaveh R. Ghazi

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).