Welcome! Log In Create A New Profile

Advanced

Lighttpd -> nginx, php segfaults sometimes

Posted by klapskurred 
Lighttpd -> nginx, php segfaults sometimes
January 27, 2012 10:01AM
Hello,

I converted my lighttpd config to nginx (1.0.11), but I am getting segfaults in php with nginx that I never had a problem with in lighttpd. I am using spawn-fcgi to spawn the php instances, tried the original version and an updated version, neither seemed to make any difference. I am using a custom forked PHP 4.4.9 (with eAccelerator), which I suspect is what nginx is not playing nice with. Using the latest 1.x branch of lighttpd has no issues, however.

Here are some logs: (actual site removed, so as to not be advertising)
nginx error log:
2012/01/26 21:13:33 [error] 15585#0: *367626 upstream prematurely closed connection while reading response header from upstream, client: 66.249.72.22, server: forums.mysite.com, request: "GET /info.php/info.php?p=12&l=21 HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fastcgi.sock:", host: "forums.mysite.com"
2012/01/26 21:16:20 [error] 15583#0: *388310 upstream prematurely closed connection while reading response header from upstream, client: 83.243.57.5, server: forums.mysite.com, request: "GET /index.php/admin/categories.php/login.php?cPath=&action=new_product_preview HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fastcgi.sock:", host: "forums.mysite.com"
2012/01/26 21:16:21 [error] 15583#0: *388358 upstream prematurely closed connection while reading response header from upstream, client: 83.243.57.5, server: forums.mysite.com, request: "GET /index.php/admin/file_manager.php/login.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-fastcgi.sock:", host: "forums.mysite.com"

/var/log/messages
Jan 26 21:13:33 media kernel: php[15596]: segfault at 0000000000000000 rip 000000372c278d80 rsp 00007fffe482dd68 error 4
Jan 26 21:16:20 media kernel: php[15597]: segfault at 0000000000000000 rip 000000372c278d80 rsp 00007fffe482dd68 error 4
Jan 26 21:16:21 media kernel: php[15609]: segfault at 0000000000000000 rip 000000372c278d80 rsp 00007fffe482dd68 error 4

One thing I noticed is the malformed urls, but this degrades fine in practice. The other obvious thing is the "upstream prematurely closed connection" error, which when I matched up more lines, it was always this type of error. It seems that whatever nginx is doing to terminate the php (during a connection interrupted) is causing it to segfault. The main fcgi process seems to respawn them after a crash, but I'm worried about leaving this running in production, and have switched back to lighttpd for the time being, until a workable resolution is found.

If I have some time, I'll write/use a test app that closes the connection after receiving data, rather than using a connection-close header directive. This would isolate this as in fact a bug with nginx and the php/fastcgi version I'm using.

Final thought: There is a slight difference in my config of the php children, with lighttpd I have 6 workers that spawn 16 children each (96 total), but with nginx, I just had a single socket that spawned 64 children. I would be surprised if this made any difference, but wanted to add it for completion sake.

My apologies if this is in the wrong forum, I could not find a bug report forum. Please move there if possible, or if that is a more appropriate location.

Thanks in advance!
Re: Lighttpd -> nginx, php segfaults sometimes
January 27, 2012 10:55AM
Just wrote a script to try and deduce if it was the connection closing prematurely or not, but it's not. It is however an invalid url that causes it every time. I suppose I could turn off the fix urls option in the php to see if that fixes it, but that may also break other things.

So, it looks like requesting a url like: /info.php/info.php?p=12&l=21 instead of /info.php?p=12&l=21 will cause the php to segfault every time. Why does nginx do this, but lighttpd does not (same config otherwise)? Is there a way to make nginx not do this?

Thanks!
Re: Lighttpd -> nginx, php segfaults sometimes
January 27, 2012 11:13AM
I set cgi.fix_pathinfo=0 and this seems to have solved the segfaults. Still, I don't think nginx should be crashing php, so it would still technically be a bug of some type. :)

Thanks!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 308
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready