# Memory leak

- Thread: https://externals.io/message/11482
- Original archive: https://news-web.php.net/php.internals/11482
- Started by Andi Gutmans on 2004-07-22T21:25:57+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #11482 — Andi Gutmans — 2004-07-22T21:25:57+00:00

URL: https://externals.io/message/11482#11482

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

---

## #11498 — Marcus Boerger — 2004-07-23T06:44:56+00:00

URL: https://externals.io/message/11482#11498 · In reply to: #11482

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

---

## #11512 — Andi Gutmans — 2004-07-23T15:42:45+00:00

URL: https://externals.io/message/11482#11512 · In reply to: #11482

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:
>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:
>
> > […]
>
> > […]
>
>
>
>
>--
>Best regards,
>  Marcus                            mailto:helly@php.net

---

## #11513 — Ilia Alshanetsky — 2004-07-23T15:54:27+00:00

URL: https://externals.io/message/11482#11513 · In reply to: #11512

> 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
