# [solved] apache2/mod_php: segfaults and 'unexpec reloc type'

## bladebreak

I've been running apache2 and mod_php successfully for about a year and a half on my P3 gentoo box. To keep the box up to date, I try to emerge -u world about once a month. Sometimes doing this has broken apache or mod_php, but usually remerging the offending package clears up the problem.

After this weekend's update, though, I've been unable to get apache to successfully load mod_php. Across multiple unmerges and remerges, one of the below three symptoms has always shown up:

 Apache segfaults on startup when mod_php is enabled

 Apache errors on the startup line with

```
 * Apache2 has detected a syntax error in your configuration files:

Syntax error on line 6 of /etc/apache2/modules.d/70_mod_php.conf:

Cannot load /usr/lib/apache2/modules/libphp4.so into server: /usr/lib/apache2/modules/libphp4.so: unexpected reloc type 0xb9
```

 Apache loads successfully, but child processes segfault when they try to serve a PHP page

To clarify, one of the above will happen and continue to happen until I unmerge apache/php/mod_php. When I remerge, I will (seemingly randomly to me) get one of the above problems.

I'm running x86, so the versions in question are:

net-www/apache-2.0.54-r31

dev-php/php-4.4.0-r1

dev-php/mod_php-4.4.0-r3

make.conf:

```

CFLAGS="-O2 -march=pentium3 -fomit-frame-pointer -pipe"

CHOST="i686-pc-linux-gnu"

CXXFLAGS="${CFLAGS}"

USE="apache2 php ssl mmx mmx2 sse tiff -cups -arts -avi -encode -gtk -gtk2 -imlib -kde -mad -mikmod -motif -mpeg -oggvorbis -opengl -oss -pdflib -qt -quicktime -svga -truetype -xmms -X -xv -gnome -xprint"

MAKEOPTS="-j2"

FEATURES=""

```

Nothing is masked/flagged/keyworded in /etc/portage/*

I am using the vanilla apache config with "-D PHP4" added to /etc/conf.d/apache2.

I don't have a lot of experience with strace/gdb, but I didn't notice any glaring system error messages coming back from strace before the segfault (case #1, app segfaulting on start is what's currently happening). Here are the last few lines:

```

open("/usr/lib/libgcrypt.so.11", O_RDONLY) = 5

read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360?\0"..., 512) = 512

fstat64(5, {st_mode=S_IFREG|0755, st_size=320324, ...}) = 0

mmap2(NULL, 318948, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0xb7182000

mmap2(0xb71cb000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x48) = 0xb71cb000

close(5)                                = 0

open("/usr/lib/libgpg-error.so.0", O_RDONLY) = 5

read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p\6\0\000"..., 512) = 512

fstat64(5, {st_mode=S_IFREG|0755, st_size=11192, ...}) = 0

mmap2(NULL, 13600, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0xb717e000

mmap2(0xb7181000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x2) = 0xb7181000

close(5)                                = 0

mprotect(0xb76a9000, 4149248, PROT_READ|PROT_WRITE) = 0

--- SIGSEGV (Segmentation fault) @ 0 (0) ---

+++ killed by SIGSEGV (core dumped) +++

```

and the gdb backtrace:

```

#0  0xb7ff4c64 in _dl_relocate_object () from /lib/ld-linux.so.2

#1  0xb7c675f8 in getutmpx () from /lib/libc.so.6

#2  0xb7ff6986 in _dl_catch_error () from /lib/ld-linux.so.2

#3  0xb7c67980 in _dl_open () from /lib/libc.so.6

#4  0xb7c97d2a in ?? () from /lib/libdl.so.2

#5  0xfffffffe in ?? ()

#6  0x00000028 in ?? ()

#7  0x000e9018 in ?? ()

#8  0xb8001fb4 in ?? () from /lib/ld-linux.so.2

#9  0xb8001c80 in _dl_argv_internal () from /lib/ld-linux.so.2

#10 0x0808d2d1 in _IO_stdin_used ()

#11 0xbfffef08 in ?? ()

#12 0xb7ff6986 in _dl_catch_error () from /lib/ld-linux.so.2

#13 0xb7ff6986 in _dl_catch_error () from /lib/ld-linux.so.2

#14 0xb7c982b1 in dlerror () from /lib/libdl.so.2

#15 0xb7c97d81 in dlopen () from /lib/libdl.so.2

#16 0xb7d84997 in apr_dso_load () from /usr/lib/libapr-0.so.0

#17 0x00000102 in ?? ()

#18 0xbffff530 in ?? ()

#19 0xb7d7431f in apr_array_push () from /usr/lib/libapr-0.so.0

#20 0xbfffef98 in ?? ()

#21 0x080bf9c0 in ?? ()

#22 0x080f9520 in ?? ()

#23 0x00000004 in ?? ()

#24 0x080be320 in ?? ()

#25 0x0808d2d1 in _IO_stdin_used ()

#26 0x00000004 in ?? ()

#27 0x080662bf in ap_allow_standard_methods ()

#28 0xb7b8fde8 in ?? () from /lib/libc.so.6

```

I've tried the suggestions in this thread about using equery and recompiling the dependancies of apache/php/mod_php to no avail. Searching on the specific error messages coming back hasn't panned out. Could someone a bit more senior than I in the ways of debugging point me in the right direction to isolating this fault?Last edited by bladebreak on Mon Oct 10, 2005 8:01 pm; edited 1 time in total

----------

## llongi

Well, a better GDB backtrace could definitely help, for a good tutorial on debugging:

http://www.gentoo.org/doc/en/bugzilla-howto.xml#doc_chap2

Also, do you run a Hardened-Gentoo system? Hardened-kernel? PaX enabled?

Best regards, CHTEKK.

----------

## bladebreak

Thanks for the debugging page tip - I'll recompile with debugging symbols and hopefully that'll point me in the right direction. I'll post the results of the backtrace when that's done.

I'm just running the basic 2.6 kernel system - no hardened, no PaX, nothing fancy or special.

Thanks

----------

## bladebreak

Ok, here's the backtrace with symbols in (sorry about the length):

```

#0  0xb7ff4d20 in _dl_relocate_object (l=0x81033b0, scope=0x810355c, lazy=0, consider_profiling=0) at dl-machine.h:515

#1  0xb7c676e8 in dl_open_worker (a=0xbfffedd0) at dl-open.c:343

#2  0xb7ff6986 in _dl_catch_error (objname=0xbfffedc8, errstring=0xbfffedcc, operate=0xb7c67010 <dl_open_worker>, 

    args=0xbfffedd0) at dl-error.c:161

#3  0xb7c67a70 in *__GI__dl_open (file=0x80f9528 "/usr/lib/apache2/modules/libphp4.so", mode=-2147483390, 

    caller_dlopen=0xb7d84997, nsid=-2) at dl-open.c:577

#4  0xb7c97d2a in dlopen_doit (a=0xbfffef70) at dlopen.c:59

#5  0xb7ff6986 in _dl_catch_error (objname=0x809d220, errstring=0x809d224, operate=0xb7c97ce0 <dlopen_doit>, 

    args=0xbfffef70) at dl-error.c:161

#6  0xb7c982b1 in _dlerror_run (operate=0xb7c97ce0 <dlopen_doit>, args=0xbfffef70) at dlerror.c:162

#7  0xb7c97d81 in __dlopen (file=0xb76b87f0 "e\a", mode=135279536) at dlopen.c:78

#8  0xb7d84997 in apr_dso_load (res_handle=0x6eed70cd, path=0x6eed70cd <Address 0x6eed70cd out of bounds>, 

    pool=0x80a3e28) at dso.c:138

#9  0x0806634f in load_module (cmd=0xbffff550, dummy=0x6eed70cd, modname=0x80f9500 "php4_module", 

    filename=0x4 <Address 0x4 out of bounds>) at mod_so.c:240

#10 0x0806995d in invoke_cmd (cmd=0x808da40, parms=0xbffff550, mconfig=0xbffff1a0, args=0x81003c4 "") at config.c:702

#11 0x0806aa0e in execute_now (cmd_line=0x80f94a8 "LoadModule", args=0x6eed70cd <Address 0x6eed70cd out of bounds>, 

    parms=0xbffff550, p=0x80a3e28, ptemp=0x80cfed8, sub_tree=0x6eed70cd, parent=0x0) at config.c:1335

#12 0x0806a1e7 in ap_build_config_sub (p=0x80a3e28, temp_pool=0x80cfed8, l=0x81033b0 "", parms=0xbffff550, 

    current=0xbffff224, curr_parent=0xbffff228, conftree=0xbffff1e8) at config.c:914

#13 0x0806a388 in ap_build_cont_config (p=0x80a3e28, temp_pool=0x80cfed8, parms=0xbffff550, current=0xbffff224, 

    curr_parent=0xbffff228, orig_directive=0x8091e04 "<IfModule") at config.c:1012

#14 0x0807bc2b in start_ifmod (cmd=0xbffff550, mconfig=0xbffff2c0, arg=0x80f9489 "sapi_apache2.c") at core.c:1901

#15 0x08069857 in invoke_cmd (cmd=0x8094210, parms=0xbffff550, mconfig=0xbffff2c0, args=0x80fd3aa "") at config.c:676

#16 0x0806aa0e in execute_now (cmd_line=0x80f9428 "<IfModule", args=0x6eed70cd <Address 0x6eed70cd out of bounds>, 

    parms=0xbffff550, p=0x80a3e28, ptemp=0x80cfed8, sub_tree=0x6eed70cd, parent=0x0) at config.c:1335

#17 0x0806a1e7 in ap_build_config_sub (p=0x80a3e28, temp_pool=0x80cfed8, l=0x81033b0 "", parms=0xbffff550, 

    current=0xbffff344, curr_parent=0xbffff348, conftree=0xbffff308) at config.c:914

#18 0x0806a388 in ap_build_cont_config (p=0x80a3e28, temp_pool=0x80cfed8, parms=0xbffff550, current=0xbffff344, 

    curr_parent=0xbffff348, orig_directive=0x8091e0e "<IfDefine") at config.c:1012

#19 0x0807bd7b in start_ifdefine (cmd=0xbffff550, dummy=0xbffff3e0, arg=0x80f9410 "PHP4") at core.c:1951

#20 0x08069857 in invoke_cmd (cmd=0x8094228, parms=0xbffff550, mconfig=0xbffff3e0, args=0x80fa397 "") at config.c:676

#21 0x0806aa0e in execute_now (cmd_line=0x80f93d0 "<IfDefine", args=0x6eed70cd <Address 0x6eed70cd out of bounds>, 

    parms=0xbffff550, p=0x80a3e28, ptemp=0x80cfed8, sub_tree=0x6eed70cd, parent=0x0) at config.c:1335

#22 0x0806a1e7 in ap_build_config_sub (p=0x80a3e28, temp_pool=0x80cfed8, l=0x81033b0 "", parms=0xbffff550, 

    current=0xbffff424, curr_parent=0xbffff428, conftree=0xbffff6f8) at config.c:914

#23 0x0806a5c8 in ap_build_config (parms=0xbffff550, p=0x80a3e28, temp_pool=0x80cfed8, conftree=0xbffff6f8)

    at config.c:1127

#24 0x0806af63 in process_resource_config_nofnmatch (s=0x80be008, 

    fname=0x80e9670 "/etc/apache2/modules.d/70_mod_php.conf", conftree=0xbffff6f8, p=0x80a3e28, ptemp=0x80cfed8, 

    depth=0) at config.c:1513

#25 0x0806b2d1 in ap_process_resource_config (s=0x80be008, fname=0x4 <Address 0x4 out of bounds>, 

    conftree=0xbffff6f8, p=0x80a3e28, ptemp=0x80cfed8) at config.c:1620

#26 0x0807c5f5 in include_config (cmd=0xbffff900, dummy=0x6eed70cd, name=0x80e7b60 "/etc/apache2/modules.d/*.conf")

    at core.c:2299

#27 0x08069857 in invoke_cmd (cmd=0x8094528, parms=0xbffff900, mconfig=0xbffff790, args=0x80d4f0d "") at config.c:676

#28 0x0806aa0e in execute_now (cmd_line=0x80e7b10 "Include", args=0x6eed70cd <Address 0x6eed70cd out of bounds>, 

    parms=0xbffff900, p=0x80a3e28, ptemp=0x80cfed8, sub_tree=0x6eed70cd, parent=0x0) at config.c:1335

#29 0x0806a1e7 in ap_build_config_sub (p=0x80a3e28, temp_pool=0x80cfed8, l=0x81033b0 "", parms=0xbffff900, 

    current=0xbffff7d4, curr_parent=0xbffff7d8, conftree=0x8099c94) at config.c:914

#30 0x0806a5c8 in ap_build_config (parms=0xbffff900, p=0x80a3e28, temp_pool=0x80cfed8, conftree=0x8099c94)

    at config.c:1127

#31 0x0806af63 in process_resource_config_nofnmatch (s=0x80be008, fname=0x80be8a0 "/etc/apache2/httpd.conf", 

    conftree=0x8099c94, p=0x80a3e28, ptemp=0x80cfed8, depth=0) at config.c:1513

#32 0x0806b0eb in ap_process_resource_config (s=0x80be008, fname=0x80be8a0 "/etc/apache2/httpd.conf", 

    conftree=0x8099c94, p=0x80a3e28, ptemp=0x80cfed8) at config.c:1549

#33 0x0806bbf5 in ap_read_config (process=0x6eed70cd, ptemp=0x80cfed8, filename=0x808e87f "/etc/apache2/httpd.conf", 

    conftree=0x8099c94) at config.c:1892

#34 0x0806e2b8 in main (argc=3, argv=0xbffffb64) at main.c:532

```

Maybe I just don't know what I'm looking for, but nothing seems to be jumping out at me. Does this point to a problem with dl-machine.h ? An incompatibility between glibc and apache/php?

----------

## bladebreak

I was able to fix the problem by re-merging linux-headers, then glibc, then apache/php/mod_php

Even though linux-headers was showing as a remerge, there was a download size associated with it, so I'm not sure if maybe there was a small fix made to the package that cleared up my problem.

----------

