Extension causes sporadic segfaults

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi NG,

I got some difficult problem that drives me nuts.

I wrote a relatively simple extension that reads binary files and
extracts some data. If I call the script, that uses my extension via
webbrowser, apache sometimes segfaults with:

*** glibc detected *** free(): invalid next size (normal):
0x0000555555a7c240 ***
[Thu Jun 21 11:57:59 2007] [notice] child pid 2487 exit signal Aborted (6)

A backtrace with gdb attached to apache shows:

#0  0x00002b080b52621d in raise () from /lib64/tls/libc.so.6
#1  0x00002b080b527a1e in abort () from /lib64/tls/libc.so.6
#2  0x00002b080b55b291 in __libc_message () from /lib64/tls/libc.so.6
#3  0x00002b080b560eae in _int_free () from /lib64/tls/libc.so.6
#4  0x00002b080b5611f6 in free () from /lib64/tls/libc.so.6
#5  0x00002b0810258b53 in _efree () from /etc/httpd/modules/libphp4.so
#6  0x00002b081025fc56 in _zval_ptr_dtor () from
#7  0x00002b081026ebe6 in zend_hash_clean () from
#8  0x00002b081027c8f2 in execute () from /etc/httpd/modules/libphp4.so
#9  0x00002b081027b3e2 in execute () from /etc/httpd/modules/libphp4.so
#10 0x00002b081026a00e in zend_execute_scripts () from
#11 0x00002b081023d733 in php_execute_script () from
#12 0x00002b0810284b89 in execute () from /etc/httpd/modules/libphp4.so
#13 0x00005555555719f3 in ap_run_handler () from /usr/sbin/httpd
#14 0x0000555555571eb1 in ap_invoke_handler () from /usr/sbin/httpd
#15 0x000055555556ecb8 in ap_process_request () from /usr/sbin/httpd
#16 0x000055555556a089 in _start () from /usr/sbin/httpd
#17 0x000055555557b693 in ap_run_process_connection () from /usr/sbin/httpd
#18 0x000055555556fb20 in ap_graceful_stop_signalled () from /usr/sbin/httpd
#19 0x000055555556fdfa in ap_graceful_stop_signalled () from /usr/sbin/httpd
#20 0x000055555556fea4 in ap_graceful_stop_signalled () from /usr/sbin/httpd
#21 0x00005555555705db in ap_mpm_run () from /usr/sbin/httpd
#22 0x0000555555576cef in main () from /usr/sbin/httpd

with valgrind php -f myscript.php I tested for mem leaks, but valgrind
doesn't detect anything.

If I debug the script directly with:

gdb php
run myscript.php

I cannot reproduce the problem.

Any idea what could be wrong, besides a bug in php or apache?

My target machine is Cent OS 4.4 x86_64 with php 4.3.9

Thanks Stefan

Re: [SOLVED]Extension causes sporadic segfaults

I was able to find and fix the bug myself. As soon as i installed php
5.1 I was able to reproduce the error with the gdb and fix it.

Stefan Braumeister schrieb:
Quoted text here. Click to load it

Site Timeline