Ilia Alshanetsky wrote:
There is a rather nasty crash possible in PHP due to the usage of the alloca() function as can be demonstrated by bug #28064.
Simpler bug replication case:
php -r ' $a = str_repeat("a", 1024 * 1024 * 6); defined($a); '



The following two fragments will lead to virtually identical code:

    void foo()
    {
        char bar[2048];
        ...
    }

and

    void foo()
    {
        char *bar = alloca(2048);
        ....

They both start out by moving the stack pointer down 2k to leave enough room for bar, and they will both crash in a similar way if the stack doesn't have enough room available.

I think that not alloca() itself but its improper use is the problem here. Any function will cause a crash if you call it when your stack is full. Just be sensible about when (not to) use it.

--
Ard

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to