Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Sep 2016 15:56:49 +0000
From:      twilight <pipfstarrd@openmailbox.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Is replacing alloca(3) where possible a good thing to do?
Message-ID:  <f71ce065-0994-9deb-2457-544f90a26105@openmailbox.org>
In-Reply-To: <bd0607f1-2224-02db-e430-6c34e42297bf@freebsd.org>
References:  <d192dbeb-5647-e552-9db1-b478aa7ac057@FreeBSD.org> <bd0607f1-2224-02db-e430-6c34e42297bf@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f71ce065-0994-9deb-2457-544f90a26105>