From owner-freebsd-hackers@freebsd.org Wed Sep 14 16:02:32 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65459BDAB27 for ; Wed, 14 Sep 2016 16:02:32 +0000 (UTC) (envelope-from pipfstarrd@openmailbox.org) Received: from smtp1.openmailbox.org (smtp16.openmailbox.org [62.4.1.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2A0A61567 for ; Wed, 14 Sep 2016 16:02:31 +0000 (UTC) (envelope-from pipfstarrd@openmailbox.org) Received: by mail.openmailbox.org (Postfix, from userid 20002) id 489FE202423; Wed, 14 Sep 2016 17:56:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1473868591; bh=PHR8gWjoQMEqhs0G/qOMkNZJhnRIy9btSgO11P5O2a0=; h=Subject:To:References:From:Date:In-Reply-To:From; b=QElH6FoQ3gJipShiNTrusA18H6No8tjzyqYlwn6T8N+V1xGv0qURtlAHFxmmJNMCi LIFiXNGA9vH5PuzZr76Te4NghAQBOl1+zb1pMahkJSUMERVyYI4XAhPtbC6rJkIIAu hWoltuDKERSsNx4TvJ9fBpdiuqr/7m4DAFP3NYug= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on h4 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_RECEIVED, NO_RELAYS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Subject: Re: Is replacing alloca(3) where possible a good thing to do? DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1473868591; bh=PHR8gWjoQMEqhs0G/qOMkNZJhnRIy9btSgO11P5O2a0=; h=Subject:To:References:From:Date:In-Reply-To:From; b=QElH6FoQ3gJipShiNTrusA18H6No8tjzyqYlwn6T8N+V1xGv0qURtlAHFxmmJNMCi LIFiXNGA9vH5PuzZr76Te4NghAQBOl1+zb1pMahkJSUMERVyYI4XAhPtbC6rJkIIAu hWoltuDKERSsNx4TvJ9fBpdiuqr/7m4DAFP3NYug= To: freebsd-hackers@freebsd.org References: From: twilight Message-ID: Date: Wed, 14 Sep 2016 15:56:49 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Sep 2016 16:02:32 -0000 > The one time I tried to use it, it went very badly, as it returns a > pointer, but the actual amount of memory was less than I had requested, > and so it smashed everything. That is a known issue with alloca, so it shouldn't be used with big amounts of memory (it creates objects on stack, so stack overflow can be reached easily). But, well, creating a really big array would do the same. Also, deep recursion will also smash the stack. So we don't have a deal like "remove alloca and your stack will be safe". But still, it's obsolete and compiler dependent. I'd better not stick to it. -- Cheers~ PGP key fingerprint: 07B3 2177 3E27 BF41 DC65 CC95 BDA8 88F1 E9F9 CEEF You can retrieve my public key at pgp.mit.edu.