From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Chris Faylor Cc: gdb@sources.redhat.com Subject: Re: alloca is bad? Date: Sun, 12 Nov 2000 15:16:00 -0000 Message-id: <3A0F2306.474C70E1@cygnus.com> References: <20001109212032.A26464@redhat.com> <20001109213750.28987@cse.cygnus.com> <20001109222231.A26675@redhat.com> <3A0DA348.6BDDAFD4@cygnus.com> <200011120538.AAA01237@indy.delorie.com> <3A0E4F83.5F9D97FF@cygnus.com> <200011121216.HAA01483@indy.delorie.com> <20001112133936.A29086@redhat.com> X-SW-Source: 2000-11/msg00109.html Chris Faylor wrote: > I've debugged many cases of stack corruption over my disgustingly long > career as a programmer. I can't remember a specific case that troubled > me for very long. I can remember, at least two cases where I spent days > trying to track down heap corruption problems, however. As they say, our energy efficency units have varied. > Nick Duffek has requested that the procedures for determining > programming guidelines in GDB be clarified. The feeling that I get from > Andrew and Fernando is that this alloca discussion has raged on before > and that the issue had been decided time ago. I've checked the mailing > list archives and I don't see any definitive statements about this > subject, however. If there is a document that says "Don't Use alloca > and Here's Why" no one has pointed it out yet. Largely maintainer wim and folk law. To re-iterate earlyer points. The official problem with alloca() is that it is very non-portable. You can be pretty sure problems with this date back to when GDB was first written and, consequently, the exact details are now well and truely lost in time. The BSD man page has: BUGS The alloca() function is machine dependent; its use is discouraged. the Solaris man page has: WARNINGS .... alloca() is machine-, compiler-, and most of all, system- dependent. Its use is strongly discouraged. With regard to multi-arch, the decision to allow alloca() was strictly pragmatic - using it was far less error proned then trying to convert all dynamic arrays to cleanups. Part of the pragmatism behind it was that it was thought that all the systems that had broken alloca() implementations had long-ago been switched off. > Since at least four GDB maintainers have expressed their desire to > use alloca, is that an adequate quorom? What's the procedure here? Are > we eventually going to come to a decision and document it? Or, are we > going to keep wrangling until someone gets tired? See the threads originating from: http://sources.redhat.com/ml/gdb/2000-11/msg00085.html Andrew