# Sick apache2 [SOLVED - definitively]

## binro

I have noticed the following in the apache2 logs:

Oct 30 21:45:16 opal apache2[25849]: [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

Oct 30 21:45:16 opal apache2[25849]: [info] Init: Initializing OpenSSL library

Oct 30 21:45:16 opal apache2[25849]: [info] Init: Seeding PRNG with 136 bytes of entropy

Oct 30 21:45:16 opal apache2[25849]: [info] Init: Generating temporary RSA private keys (512/1024 bits)

Oct 30 21:45:16 opal apache2[25849]: [info] Init: Generating temporary DH parameters (512/1024 bits)

Oct 30 21:45:16 opal apache2[25849]: [info] Init: Initializing (virtual) servers for SSL

Oct 30 21:45:16 opal apache2[25849]: [info] Server: Apache/2.0.58, Interface: mod_ssl/2.0.58, Library: OpenSSL/0.9.8d

Oct 30 21:45:16 opal apache2[25850]: [notice] Digest: generating secret for digest authentication ...

Oct 30 21:45:16 opal apache2[25850]: [notice] Digest: done

Oct 30 21:45:16 opal apache2[25850]: [info] Init: Initializing OpenSSL library

Oct 30 21:45:16 opal apache2[25850]: [info] Init: Seeding PRNG with 136 bytes of entropy

Oct 30 21:45:16 opal apache2[25850]: [info] Init: Generating temporary RSA private keys (512/1024 bits)

Oct 30 21:45:16 opal apache2[25850]: [info] Init: Generating temporary DH parameters (512/1024 bits)

Oct 30 21:45:16 opal apache2[25850]: [info] Shared memory session cache initialised

Oct 30 21:45:16 opal apache2[25850]: [info] Init: Initializing (virtual) servers for SSL

Oct 30 21:45:16 opal apache2[25850]: [info] Server: Apache/2.0.58, Interface: mod_ssl/2.0.58, Library: OpenSSL/0.9.8d

Oct 30 21:45:17 opal apache2[25850]: [notice] Apache configured -- resuming normal operations

Oct 30 21:45:17 opal apache2[25850]: [info] Server built: Sep  7 2006 18:57:19

Oct 30 21:45:17 opal apache2[25855]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 21:45:17 opal apache2[25856]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 21:45:17 opal apache2[25857]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 21:45:17 opal apache2[25858]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 21:45:17 opal apache2[25859]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 21:45:28 opal apache2[25869]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 21:45:50 opal apache2[25895]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 21:46:37 opal apache2[25850]: [notice] child pid 25859 exit signal Segmentation fault (11)

Oct 30 21:46:58 opal apache2[25850]: [notice] child pid 25857 exit signal Segmentation fault (11)

Oct 30 21:52:11 opal apache2[26273]: [error] (2)No such file or directory: Error attaching to shared memory

Oct 30 22:37:41 opal apache2[28350]: [error] (2)No such file or directory: Error attaching to shared memory

The segfaults are caused everytime I attempt to do an ftp using mod_ftpd. I can't find any useful hits googling on the messages. Any ideas what I can do about this? Apache is current:

[ebuild   R   ] net-www/apache-2.0.58-r2  USE="apache2 doc ldap mpm-prefork ssl -debug -mpm-itk -mpm-leader -mpm-peruser -mpm-threadpool -mpm-worker (-selinux) -static-modules -threads (-no-suexec%)" 4,651 kB

TIA

----------

## Janne Pikkarainen

Maybe you have not enabled System V IPC under kernel's make menuconfig -> General Setup?

----------

## binro

 *Janne Pikkarainen wrote:*   

> Maybe you have not enabled System V IPC under kernel's make menuconfig -> General Setup?

 

I most certainly have, I think you are in a world of pain if you do not!

----------

## Janne Pikkarainen

Well, ok then. Do you have some chroot voodoo or some tight security frameworks like SELinux in place?

----------

## Janne Pikkarainen

And what does ipcs return?

----------

## binro

No chroot or SELINUX hardening. Here is the output from ipcs:

```

opal ~ # ipcs

------ Shared Memory Segments --------

key        shmid      owner      perms      bytes      nattch     status

0x00000000 0          root      777        155648     3

0x0056a4d5 56229889   robin     660        488        1

0x00000000 24444930   root      777        4096       1          dest

0x00000000 43384835   root      777        4096       2

0x00000000 327684     root      777        4096       2

0x00000000 360453     root      777        4096       2

0x00000000 2523142    root      777        4096       1          dest

0x00000000 2555911    root      777        4096       1          dest

0x00000000 2588680    root      777        4096       1          dest

0x0056a4d6 56262665   robin     660        65536      1

0x00000000 27492362   root      777        4096       1          dest

0x00000000 27525131   root      777        4096       1          dest

0x0056a4d7 56295436   robin     660        488        1

------ Semaphore Arrays --------

key        semid      owner      perms      nsems

0x00000000 24150016   apache    600        1

0x00000000 24182785   root      600        1

0x00000000 24215554   apache    600        1

0x0056a4d5 28606467   robin     660        1

0x0056a4d7 28639236   robin     660        1

------ Message Queues --------

key        msqid      owner      perms      used-bytes   messages

opal ~ #                                                    

```

Thanks for the quick responses!   :Very Happy: 

----------

## Janne Pikkarainen

That's odd. Have you tried to strace Apache process and see what it tries to do before throwing that error message about shared memory?

If you don't already have strace installed, emerge strace, and then 

strace -o /tmp/wtf -fF /usr/sbin/apache2 -X

Then see /tmp/wtf with any text editor and look around for that shared memory error. Try to find out how and where Apache is trying to attach itself.

----------

## Dlareh

Shared memory can mean a number of different things... /dev/shm ok?

----------

## binro

```

opal ~ # df /dev/shm

Filesystem           1K-blocks      Used Available Use% Mounted on

none                    540672         0    540672   0% /dev/shm

opal ~ #

```

Nothing wrong with shm. I looked through the strace output but could find no messages about "shared memory". I am actually more worried about the segfaults when an ftp is attempted, any ideas about that?

----------

## Janne Pikkarainen

Oh, I thought those messages would be related... and only now I was awake enough to look at log timestamps. How stupid of me.  :Razz: 

I don't have personal experience about that ftp module, so unfortunately I don't know about its quirks. Anyway, some general things to check:

- File/directory permissions?

- Does this occur during anonymous ftp connection or during authenticated ftp connection? 

- Does ftp work at all or is Signal 11 jumping at you right after ftp connection attempt?

- If this an authenticated ftp connection using PAM, is there anything in other logs? /var/log/auth.log, /var/log/messages ...?

----------

## binro

The permissions, etc, are OK, this used to work. The segfault occurs as soon as the remote host connects using anonymous ftp.  There are no messages in the system logs. My first suspicion was the firewall but the same problem occurs via the LAN. It's a mystery.   :Crying or Very sad: 

----------

## binro

 *binro wrote:*   

> The permissions, etc, are OK, this used to work. The segfault occurs as soon as the remote host connects using anonymous ftp.  There are no messages in the system logs. My first suspicion was the firewall but the same problem occurs via the LAN. It's a mystery.  

 

...and today I look at my logging and see:

Nov  2 03:10:23 opal apache2[22459]: [notice] Graceful restart requested, doing restart

Nov  2 03:10:24 opal apache2[22459]: [notice] Digest: generating secret for digest authentication ...

Nov  2 03:10:24 opal apache2[22459]: [notice] Digest: done

Nov  2 03:10:24 opal apache2[22459]: [info] Init: Initializing OpenSSL library

Nov  2 03:10:24 opal apache2[22459]: [info] Init: Seeding PRNG with 136 bytes of entropy

Nov  2 03:10:24 opal apache2[22459]: [info] Init: Generating temporary RSA private keys (512/1024 bits)

Nov  2 03:10:25 opal apache2[22459]: [info] Init: Generating temporary DH parameters (512/1024 bits)

Nov  2 03:10:25 opal apache2[22459]: [info] Shared memory session cache initialised

Nov  2 03:10:25 opal apache2[22459]: [info] Init: Initializing (virtual) servers for SSL

Nov  2 03:10:25 opal apache2[22459]: [info] Server: Apache/2.0.58, Interface: mod_ssl/2.0.58, Library: OpenSSL/0.9.8d

Nov  2 03:10:25 opal apache2[22459]: [notice] Apache configured -- resuming normal operations

Nov  2 03:10:25 opal apache2[22459]: [info] Server built: Sep  7 2006 18:57:19

No more memory error messages and ftp now works again! What is different when it restarts itself to when it gets started by the init script?

----------

## Janne Pikkarainen

 *binro wrote:*   

> 
> 
> No more memory error messages and ftp now works again! What is different when it restarts itself to when it gets started by the init script?

 

Well that is odd! There should be no difference, at least not any which should make any difference.  

During "self-restart" (for example, during log rotation) Apache normally just sends HUP signal, which makes it to re-open all file handles (so logging goes to correct log even after log rotation etc), and init script should make a full stop -> start.

What other Apache modules you have installed  than ftpd?

----------

## binro

 *Janne Pikkarainen wrote:*   

> 
> 
> What other Apache modules you have installed  than ftpd?

 

APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5 -D SSL -D DOC -D FTPD"

Pretty much the standard ones shipped in the package.

----------

## Janne Pikkarainen

Ok, because this line bugs me:

```
Nov 2 03:10:25 opal apache2[22459]: [info] Shared memory session cache initialised
```

memcached? Something other?

----------

## binro

I assumed that line was a Good Thing! A quick google seems to indicate it's something to do with the SSL module.

----------

## Janne Pikkarainen

Hmm. Might be. But maybe it earlier left some corpses behind to that shared memory area it wanted and that somehow got cleaned up, and that made everything work? I don't know  :Smile: 

----------

## binro

I don't know either but now I have a solution! I will mark this thread solved.

Thanks for the help.   :Very Happy: 

----------

## binro

The problem came back at the next restart. Someone kindly emailed me the definitive solution. Stop apache, delete all the files owned by apache in /tmp and restart. Problem solved. So simple, yet no one knew.   :Confused: 

----------

## motosauro

 *binro wrote:*   

> The problem came back at the next restart. Someone kindly emailed me the definitive solution. Stop apache, delete all the files owned by apache in /tmp and restart. Problem solved. So simple, yet no one knew.  

 

Cleaning the /tmp of all apache owned files solved the problem for me too.

My guess is: prior to emerging apache related stuff => /etc/init.d/apache2 stop

Next time I will and see if this odd problem shows up again.

Thanks anyhow, you saved my day  :Smile: 

----------

