Segfault in HEAD & PHP_4_3 (and possible patch)

php.internals

Antony Dovgal

22 years ago
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

Wez Furlong

22 years ago
The memory manager will deliberately segfault if an allocation fails in a debug build. Having said that, your patch seems ok anyway. --Wez. On Wed, 24 Sep 2003, Antony Dovgal wrote:

Antony Dovgal

22 years ago
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