# FreeBSD 10.0 Apache+PHP Segmentation fault



## Young (Sep 15, 2014)

Hi,

I use this OS/Software combination for years, but after moving myself to the FreeBSD 10.0 (before was 9.2) started the headaches. It was very annoying to deal with the lack of GCC and Bind in the base system, but this is subject for another thread. My problem is about random Segmentation faults in Apache with PHP. At the first I thought that was because the old version of PHP (5.4.32) but the same problem occurred in the latest PHP version (5.6.0) compiled same as before. I've tried debugging, but no luck. The crash occurs in any PHP script, with no warning/error in the logs. No hardware problem related, same behavior on an Cloud server. Tried to compile without PHAR but the problem persists. Seems to be an FreeBSD 10.0 conflict. Any help will be appreciated.

error_log

```
[Sun Sep 14 22:15:20.114756 2014] [core] [pid 80717:tid 34410095616] AH00052: child pid 81760 exit signal Segmentation fault (11)
[Sun Sep 14 22:15:22.180905 2014] [core] [pid 80717:tid 34410095616] AH00052: child pid 81727 exit signal Segmentation fault (11)
[Sun Sep 14 22:27:14.973207 2014] [core] [pid 80717:tid 34410095616] AH00052: child pid 81807 exit signal Segmentation fault (11)
```

Apache 2.4.10 compile options

```
./configure --prefix=/usr/apache --exec-prefix=/usr --sysconfdir=/etc/apache --enable-modules=none --enable-mods-static="authn_core authn_file authz_host authz_groupfile authz_user authz_core auth_basic socache_shmcb so include filter mime log_config env expires headers setenvif version ssl unixd status autoindex suexec cgi negotiation dir actions userdir alias rewrite"
```

PHP 5.6.0 compile options

```
./configure --prefix=/usr/php5 --exec-prefix=/usr --with-apxs2=/usr/bin/apxs --with-config-file-path=/etc --with-openssl --with-zlib --with-bz2 --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --enable-mbstring --with-mcrypt --with-mssql --with-mysql --with-mysql-sock=/tmp/mysql.sock --with-mysqli=/usr/local/bin/mysql_config --enable-sockets --enable-zip
```

php.ini custom configurations

```
expose_php = Off
error_reporting = E_ALL & ~E_NOTICE
date.timezone = "America/Sao_Paulo"
default_charset = ""
```

gdb() output

```
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 807418000 (LWP 100188/httpd)]
0x00000008038b6157 in zend_stack_push (stack=0x808a9e4e8, element=0x808a9e4c8, size=<value optimized out>) at zend_stack.c:42
42              stack->elements[stack->top] = (void *) emalloc(size);
Current language:  auto; currently minimal
(gdb) bt
#0  0x00000008038b6157 in zend_stack_push (stack=0x808a9e4e8, element=0x808a9e4c8, size=<value optimized out>) at zend_stack.c:42
#1  0x000000080387ee63 in compile_file (file_handle=<value optimized out>, type=<value optimized out>, tsrm_ls=0x8089a4900) at zend_language_scanner.l:583
#2  0x0000000803752abf in phar_compile_file (file_handle=0x7ffffdbed920, type=2, tsrm_ls=0x8089a4900) at phar.c:3411
#3  0x00000008038b9735 in zend_execute_scripts (type=2, tsrm_ls=0x8089a4900, retval=0x0, file_count=1) at zend.c:1307
#4  0x000000080394cb8a in php_handler (r=0x80ba1c0a0) at sapi_apache2.c:669
#5  0x0000000000471fdb in ap_run_handler ()
#6  0x00000000004728bd in ap_invoke_handler ()
#7  0x00000000004b8489 in ap_process_async_request ()
#8  0x00000000004b301e in ap_process_http_async_connection ()
#9  0x00000000004b2d12 in ap_process_http_connection ()
#10 0x000000000048326b in ap_run_process_connection ()
#11 0x000000000053b2df in process_socket ()
#12 0x0000000000537b29 in worker_thread ()
#13 0x000000080208c4a4 in pthread_create () from /lib/libthr.so.3
#14 0x0000000000000000 in ?? ()
(gdb) bt full
#0  0x00000008038b6157 in zend_stack_push (stack=0x808a9e4e8, element=0x808a9e4c8, size=<value optimized out>) at zend_stack.c:42
No locals.
#1  0x000000080387ee63 in compile_file (file_handle=<value optimized out>, type=<value optimized out>, tsrm_ls=0x8089a4900) at zend_language_scanner.l:583
        original_lex_state = {yy_leng = 0, yy_start = 0x0, yy_text = 0x0, yy_cursor = 0x0, yy_marker = 0x0, yy_limit = 0x0, yy_state = 0, state_stack = {top = 0, max = 0, elements = 0x0}, in = 0x0, lineno = 0, filename = 0x0,
  script_org = 0x0, script_org_size = 0, script_filtered = 0x0, script_filtered_size = 0, input_filter = 0, output_filter = 0, script_encoding = 0x0}
        retval_znode = {op_type = 1, u = {op = {constant = 1, var = 1, num = 1, hash = 1, opline_num = 1, jmp_addr = 0x1, zv = 0x1, literal = 0x1, ptr = 0x1}, constant = {value = {lval = 1, dval = 4.9406564584124654e-324, str = {
          val = 0x1 <Error reading address 0x1: Bad address>, len = 22}, ht = 0x1, obj = {handle = 1, handlers = 0x16}}, refcount__gc = 1, type = 1 '\001', is_ref__gc = 0 '\0'}, op_array = 0x1}, EA = 51444928}
        original_active_op_array = (zend_op_array *) 0x0
        original_in_compilation = 0 '\0'
        compiler_result = <value optimized out>
        retval = <value optimized out>
#2  0x0000000803752abf in phar_compile_file (file_handle=0x7ffffdbed920, type=2, tsrm_ls=0x8089a4900) at phar.c:3411
        __bailout = {{_sjb = {34417748607, 140737450531104, 140737450530424, 140737450530720, 140737450531232, 0, 0, 34504067328, 140737450476415, 34389426431, 1280, 34359738368}}}
        __bailout = {{_sjb = {34417748607, 140737450531104, 140737450530424, 140737450530720, 140737450531232, 0, 0, 34504067328, 140737450476415, 34389426431, 1280, 34359738368}}}
        __orig_bailout = (sigjmp_buf *) 0x7ffffdbed9a0
        name = 0x0
        phar = (phar_archive_data *) 0x50
        name = 0x0
        res = <value optimized out>
        failed = Error accessing memory address 0x0: Bad address.
```

Thanks.


----------



## wblock@ (Sep 15, 2014)

Did you rebuild all ports after upgrading to FreeBSD 10?


----------



## Young (Sep 15, 2014)

wblock@ said:
			
		

> Did you rebuild all ports after upgrading to FreeBSD 10?


No upgrade. Fresh install.


----------



## Young (Sep 16, 2014)

Solution provided by Apache Bugzilla: https://issues.apache.org/bugzilla/show_bug.cgi?id=56984

Thank you.


----------



## zzatskl (Sep 18, 2014)

Thanks for hunting this one down. I've been scratching my head on it for a few months now


----------

