Memory leak

php.internals

Andi Gutmans

22 years ago
The executor() change from alloca() to emalloc() seems to have introduced a memory leak (found it with --enable-debug). Before I try and fix it, are we reverting back to do_alloca(), free_alloca()? (even though we should see why this memory leak is happening anyway because we don't always use alloca() for do_allocat()). Andi

Marcus Börger

22 years ago
Hello Andi, the easiest way to make the test suit for 5.1 work again is to change zend_execute.c line 1352 to: EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable), op_array->T, 1); notice the 1 instead of 0 which allocates one additional byte for every execution. regards marcus Thursday, July 22, 2004, 11:25:57 PM, you wrote:
> The executor() change from alloca() to emalloc() seems to have introduced a > memory leak (found it with --enable-debug). Before I try and fix it, are we > reverting back to do_alloca(), free_alloca()? (even though we should see > why this memory leak is happening anyway because we don't always use > alloca() for do_allocat()).
> Andi
-- Best regards, Marcus mailto:helly@php.net

Andi Gutmans

22 years ago
Why do we need one extra byte? Anyway, the question is if we should return to alloca() or not. I am slightly in favor but don't feel very strongly about it. Andi At 08:44 AM 7/23/2004 +0200, Marcus Boerger wrote:

Ilia A.

22 years ago
On July 23, 2004 11:42 am, Andi Gutmans wrote:
> Why do we need one extra byte?
We do not.
> Anyway, the question is if we should return to alloca() or not. I am > slightly in favor but don't feel very strongly about it.
Perhaps we could try a combination of the two, to ensure that no script is terminated due to a PHP crash if allocating on the stack fails. By default we can use alloca() if that fails to allocate the memory, we could use emalloc() and set a flag free code indicating which free function should be used. Ilia

Andi Gutmans

22 years ago
At 11:54 AM 7/23/2004 -0400, Ilia Alshanetsky wrote:
>On July 23, 2004 11:42 am, Andi Gutmans wrote: > > Why do we need one extra byte? > >We do not. > > > Anyway, the question is if we should return to alloca() or not. I am > > slightly in favor but don't feel very strongly about it. > >Perhaps we could try a combination of the two, to ensure that no script is >terminated due to a PHP crash if allocating on the stack fails. By default we >can use alloca() if that fails to allocate the memory, we could use emalloc() >and set a flag free code indicating which free function should be used.
I'm hesitant to slow down the general case (even if it's just an additional if()) statement. I'd revert to alloca() and we can always add a --paranoid-stack-allocation directive to configure to use emalloc() :) Andi

Ilia A.

22 years ago
On July 23, 2004 12:40 pm, you wrote:
> At 11:54 AM 7/23/2004 -0400, Ilia Alshanetsky wrote: > >On July 23, 2004 11:42 am, Andi Gutmans wrote: > > > Why do we need one extra byte? > > > >We do not. > > > > > Anyway, the question is if we should return to alloca() or not. I am > > > slightly in favor but don't feel very strongly about it. > > > >Perhaps we could try a combination of the two, to ensure that no script is > >terminated due to a PHP crash if allocating on the stack fails. By default > > we can use alloca() if that fails to allocate the memory, we could use > > emalloc() and set a flag free code indicating which free function should > > be used. > > I'm hesitant to slow down the general case (even if it's just an additional > if()) statement. I'd revert to alloca() and we can always add a > --paranoid-stack-allocation directive to configure to use emalloc() :)
The problem is that that this causes certain large script to just crash, without any meaningful information. Is the cost of 2 if()s really that pefromance prohibitive? Ilia

Andi Gutmans

22 years ago
At 12:51 PM 7/23/2004 -0400, Ilia Alshanetsky wrote:
>On July 23, 2004 12:40 pm, you wrote: > > At 11:54 AM 7/23/2004 -0400, Ilia Alshanetsky wrote: > > >On July 23, 2004 11:42 am, Andi Gutmans wrote: > > > > Why do we need one extra byte? > > > > > >We do not. > > > > > > > Anyway, the question is if we should return to alloca() or not. I am > > > > slightly in favor but don't feel very strongly about it. > > > > > >Perhaps we could try a combination of the two, to ensure that no script is > > >terminated due to a PHP crash if allocating on the stack fails. By default > > > we can use alloca() if that fails to allocate the memory, we could use > > > emalloc() and set a flag free code indicating which free function should > > > be used. > > > > I'm hesitant to slow down the general case (even if it's just an additional > > if()) statement. I'd revert to alloca() and we can always add a > > --paranoid-stack-allocation directive to configure to use emalloc() :) > >The problem is that that this causes certain large script to just crash, >without any meaningful information. Is the cost of 2 if()s really that >pefromance prohibitive?
No it's not. But 2 and 2 and 2 is :) I guess we can go with the if()'s for now.... Argh... Want to write a patch? Andi

Lukas Smith

22 years ago
message from marcus börger: "I have fixed the problem, without the need for an additional byte" regards, Lukas Smith aka Proxy

Sterling Hughes

22 years ago
dooooooooooooooooooalllllllllocccccccccccccccccaaaaaaaaaaaaaaaaaaa, damnit On Fri, 23 Jul 2004 09:54:27 -0700, Andi Gutmans <andi@zend.com> wrote:
> At 12:51 PM 7/23/2004 -0400, Ilia Alshanetsky wrote: > >On July 23, 2004 12:40 pm, you wrote: > > > At 11:54 AM 7/23/2004 -0400, Ilia Alshanetsky wrote: > > > >On July 23, 2004 11:42 am, Andi Gutmans wrote: > > > > > Why do we need one extra byte? > > > > > > > >We do not. > > > > > > > > > Anyway, the question is if we should return to alloca() or not. I am > > > > > slightly in favor but don't feel very strongly about it. > > > > > > > >Perhaps we could try a combination of the two, to ensure that no script is > > > >terminated due to a PHP crash if allocating on the stack fails. By default > > > > we can use alloca() if that fails to allocate the memory, we could use > > > > emalloc() and set a flag free code indicating which free function should > > > > be used. > > > > > > I'm hesitant to slow down the general case (even if it's just an additional > > > if()) statement. I'd revert to alloca() and we can always add a > > > --paranoid-stack-allocation directive to configure to use emalloc() :) > > > >The problem is that that this causes certain large script to just crash, > >without any meaningful information. Is the cost of 2 if()s really that > >pefromance prohibitive? > > No it's not. But 2 and 2 and 2 is :) > I guess we can go with the if()'s for now.... Argh... > Want to write a patch? > > > > Andi > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
-- ..I....I..

Andi Gutmans

22 years ago
:) Ilia, you heard the man. I don't think he leaves you much choice unless you want to risk him waiting for you in a dark alley with a surprise :) Andi At 01:09 PM 7/23/2004 -0700, Sterling Hughes wrote:

Ilia A.

22 years ago
Fine fine... let's rever it... I don't feel like carrying brass knuckles with me all the time. Ilia On July 23, 2004 04:36 pm, Andi Gutmans wrote:

George Schlossnagle

22 years ago
Sterling's not as tough as he looks. On Jul 23, 2004, at 5:05 PM, Ilia Alshanetsky wrote:

Adam Maccabee Trachtenberg

22 years ago
On Fri, 23 Jul 2004, George Schlossnagle wrote:
> Sterling's not as tough as he looks.
That's easy to say when you're 3,000 miles across the country. Then again, I know you're going to be together in Portland next week, so there's something for me to look forward to. :) -adam
-- adam@trachtenberg.com author of o'reilly's "upgrading to php 5" and "php cookbook" avoid the holiday rush, buy your copies today!