# Segfault in HEAD & PHP_4_3 (and possible patch)

- Thread: https://externals.io/message/4567
- Original archive: https://news-web.php.net/php.internals/4567
- Started by Antony Dovgal on 2003-09-24T17:49:44+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #4567 — Antony Dovgal — 2003-09-24T17:49:44+00:00

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

Hi, all!

This script (you need to compile PHP with --enable-memory-limit first):
<?
ini_set("memory_limit",0);
 `phpinfo()`;
?>
produces for me segfault with last HEAD and PHP_4_3 branch.

Backtrace:

Program received signal SIGSEGV, Segmentation fault.
_efree (ptr=0x0) at /root/CVS/php-src/Zend/zend_alloc.c:257
257             CALCULATE_REAL_SIZE_AND_CACHE_INDEX(p->size);
(gdb) bt
#0  _efree (ptr=0x0) at /root/CVS/php-src/Zend/zend_alloc.c:257
#1  0x4035268b in php_end_ob_buffer (send_buffer=1 '\001', just_flush=0 '\0') at /root/CVS/php-src/main/output.c:315
#2  0x40352a80 in php_end_ob_buffers (send_buffer=0 '\0') at /root/CVS/php-src/main/output.c:339
#3  0x40345e77 in php_request_shutdown (dummy=0x0) at /root/CVS/php-src/main/main.c:1204
#4  0x403a0f7f in apache_php_module_main (r=0x8185cbc, display_source_mode=0)
    at /root/CVS/php-src/sapi/apache/sapi_apache.c:60
#5  0x403a1b0b in send_php (r=0x8185cbc, display_source_mode=0, filename=0x0)
    at /root/CVS/php-src/sapi/apache/mod_php5.c:621
#6  0x403a1cd5 in send_parsed_php (r=0x8185cbc) at /root/CVS/php-src/sapi/apache/mod_php5.c:636
#7  0x08068eee in ap_invoke_handler ()
#8  0x0807e83e in process_request_internal ()
#9  0x0807ec74 in ap_internal_redirect ()
#10 0x0805e39a in handle_dir ()
#11 0x08068eee in ap_invoke_handler ()
#12 0x0807e83e in process_request_internal ()
#13 0x0807e89b in ap_process_request ()
#14 0x0807535f in child_main ()
#15 0x08075511 in make_child ()
#16 0x08075690 in startup_children ()
#17 0x08075d00 in standalone_main ()
#18 0x0807659a in main ()
#19 0x400d1af7 in __libc_start_main () from /lib/i686/libc.so.6

I can propose a patch, see attachment.
Dunno is this patch optimal or not, but it works for me.

---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net

---

## #4569 — Wez Furlong — 2003-09-24T19:18:28+00:00

URL: https://externals.io/message/4567#4569 · In reply to: #4567

The memory manager will deliberately segfault if an allocation fails in a debug
build.

Having said that, your patch seems ok anyway.

--Wez.



> Hi, all!
>
> This script (you need to compile PHP with --enable-memory-limit first):
> <?
> ini_set("memory_limit",0);
> `phpinfo()`;
> ?>
> produces for me segfault with last HEAD and PHP_4_3 branch.
>
> Backtrace:
>
> Program received signal SIGSEGV, Segmentation fault.
> _efree (ptr=0x0) at /root/CVS/php-src/Zend/zend_alloc.c:257
> 257             CALCULATE_REAL_SIZE_AND_CACHE_INDEX(p->size);
> (gdb) bt
> #0  _efree (ptr=0x0) at /root/CVS/php-src/Zend/zend_alloc.c:257

---

## #4605 — Antony Dovgal — 2003-09-29T13:08:26+00:00

URL: https://externals.io/message/4567#4605 · In reply to: #4569

On Wed, 24 Sep 2003 20:18:28 +0100 (BST)
Wez Furlong <wez@thebrainroom.com> wrote:

> The memory manager will deliberately segfault if an allocation fails in a debug
> build.
> 
> Having said that, your patch seems ok anyway.

hmmm.. patch is ok, but still not commited =\

---
WBR,
Antony Dovgal aka tony2001
tony2001@phpclub.net
