Httpd – Apache HTTPD – Segmentation fault when loading mod_jk module


I just set up mod_jk with my Apache httpd 2.0.52 installation, but now when I try to start Apache, it has a segmentation fault. I've checked that I am using the mod_jk compiled for 2.0.x.. built against the same version I have, in fact. I've also verified that the path I'm giving to LoadModule is correct, and the permissions and the ownership of the file are the same as the rest of the modules'. When I remove the "LoadModule" command for mod_jk from my httpd.conf, there is no segmentation fault.

Nothing shows in Apache's error logs. I have tried restarting the server with this module using both service httpd restart and httpd.

These are the last few lines returned of strace httpd -X:

gettimeofday({1292100295, 434487}, NULL) = 0
socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = -1 EAFNOSUPPORT (Address family not supported by protocol)
socket(PF_NETLINK, SOCK_RAW, 0)         = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=22378, groups=00000000}, [12]) = 0
time(NULL)                              = 1292100295
sendto(3, "\24\0\0\0\26\0\1\3\307\342\3M\0\0\0\0\0\305\333\267", 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"<\0\0\0\24\0\2\0\307\342\3MjW\0\0\2\10\200\376\1\0\0\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 664
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0\307\342\3MjW\0\0\0\0\0\0\1\0\0\0\10\0"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 20
close(3)                                = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Process 22378 detached

Has anyone had a similar problem using Apache 2.0.52 with mod_jk? I might try downloading and building the source for the Apache server and mod_jk myself if there isn't a discovered fix for this.

Best Answer

Is this a precompiled mod_jk that you found? If so, then it's simple enough to just grab the latest source for mod_jk and compile it, I suspect this is where your problem is - I've compiled mod_jk against the vendor supplied (Red Hat) Apache a lot of times without segfaults.

Make sure httpd-devel is installed (Red Hat/CentOS)

Unpack the real JDK to some path, like /usr/local/jdk1.6.0_18/

Grab the "tomcat-connectors" source from and compile it:

cd tomcat-connectors-1.2.28-src/native
./configure --with-apxs=/usr/sbin/apxs --with-java=/usr/local/jdk1.6.0_18 --enable-prefork
cp apache-2.0/ /etc/httpd/modules/

Your modules should now work as expected.