# Apache hangs on php

## kaszynek

My apache is still hanging on php code. (I've got small web application on Symfony framework)

I can't run any php code when it hangs but apache still shows correctly index of files on "localhost/".

To cause apache to hang it is enough for me to refresh 3 times web (when i do it fast it hangs).

It looks like some strange deadlock because when I have compiled apache with -threads flag then the problem has gone.

I tried also to strace apache threads and this is what I've get:

```
Process 16868 attached

accept(4, 

[HANGED HERE]

^CProcess 16868 detached

 <detached ...>
```

```
Process 16869 attached with 27 threads

[pid 16908] semop(5472256, {{0, -1, SEM_UNDO}}, 1 <unfinished ...>

[pid 16906] futex(0x7f9626cda088, FUTEX_WAIT, 2, NULL <unfinished ...>

[pid 16904] futex(0x7f9626cda088, FUTEX_WAIT, 2, NULL <unfinished ...>

[pid 16902] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 167, NULL <unfinished ...>

[pid 16900] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 165, NULL <unfinished ...>

[pid 16902] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16900] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16902] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16898] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 163, NULL <unfinished ...>

[pid 16900] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16898] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16896] futex(0x7f9626cda088, FUTEX_WAIT, 2, NULL <unfinished ...>

[pid 16898] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16894] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 161, NULL) = -1 EAGAIN (Resource temporarily unavailable)

[pid 16894] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16889] futex(0x7f9626cda088, FUTEX_WAIT, 2, NULL <unfinished ...>

[pid 16892] futex(0x7f9626cda088, FUTEX_WAIT, 2, NULL <unfinished ...>

[pid 16891] futex(0x7f9626cda088, FUTEX_WAIT, 2, NULL <unfinished ...>

[pid 16888] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 158, NULL) = -1 EAGAIN (Resource temporarily unavailable)

[pid 16888] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16885] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 155, NULL) = -1 EAGAIN (Resource temporarily unavailable)

[pid 16885] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16882] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 147, NULL <unfinished ...>

[pid 16884] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 148, NULL <unfinished ...>

[pid 16882] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16884] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16882] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16886] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 154, NULL <unfinished ...>

[pid 16881] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 151, NULL <unfinished ...>

[pid 16886] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16884] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16881] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16880] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 143, NULL <unfinished ...>

[pid 16881] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16886] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16880] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16880] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16878] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 139, NULL <unfinished ...>

[pid 16879] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 141, NULL <unfinished ...>

[pid 16877] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 137, NULL <unfinished ...>

[pid 16878] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16879] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16877] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16879] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16878] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16877] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16876] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 135, NULL <unfinished ...>

[pid 16875] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 133, NULL) = -1 EAGAIN (Resource temporarily unavailable)

[pid 16876] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16875] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16876] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16874] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 131, NULL) = -1 EAGAIN (Resource temporarily unavailable)

[pid 16873] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 129, NULL <unfinished ...>

[pid 16874] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16873] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavailable)

[pid 16873] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16872] futex(0x2183c9c, FUTEX_WAIT_PRIVATE, 171, NULL <unfinished ...>

[pid 16869] read(7, 

[STOPPED HERE]
```

this is one of hanged thread backtrace:

```
#0  0x00007f393715bd1d in read () from /lib64/libpthread.so.0

#1  0x0000000000467504 in ap_worker_pod_check ()

#2  0x000000000042a7b6 in child_main ()

#3  0x00000000004654d3 in make_child ()

#4  0x0000000000465546 in startup_children ()

#5  0x0000000000466a9d in worker_run ()

#6  0x0000000000431196 in ap_run_mpm ()

#7  0x000000000042b26f in main ()
```

any suggestions?

It seems that not only I have this problem :/

http://serverfault.com/questions/411333/apache-gets-hangs-with-defunct-while-hitting-more-concurrency-in-mpm-worker

Probably it is apc problem similar like in here:

https://forums.gentoo.org/viewtopic-t-920620-start-0.html

----------

## hydrapolic

Please post your output of 'emerge --info apache php'.

----------

## kaszynek

After the threads were disabled in apache:

http://bpaste.net/show/79270/

----------

## hydrapolic

It works ok with apache-prefork and threads disabled along with php being merged without threads? And again, it fails with threaded apache (mpm worker) and php with threads?

When using the threaded versions, how do you connect php and apache?

----------

