This is the mail archive of the
mailing list for the GCC project.
Re: Using alloca in function parameters buggy or works ???
- From: Jeffrey A Law <law at redhat dot com>
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 16 Sep 2004 09:29:03 -0600
- Subject: Re: Using alloca in function parameters buggy or works ???
- Organization: Red Hat, Inc
- References: <200409161516.i8GFGOkV010784@caip.rutgers.edu>
- Reply-to: law at redhat dot com
On Thu, 2004-09-16 at 09:16, Kaveh R. Ghazi wrote:
> 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?
I believe it was in 2.95 and probably everything leading up to
2.95 as well.
> 2. Does my example above trigger the bug?
Unfortunately, I don't recall all the parameters needed to trigger
the bug, nor do I recall if it was something that was ultimately
unfixable or not.