nginx segfault

Igor Sysoev is at rambler-co.ru
Sat Mar 31 01:10:13 MSD 2007


On Sat, Mar 31, 2007 at 12:41:32AM +0400, tr1gger wrote:

> Здравствуйте! Система linux gentoo, проц amd opteron, nginx из портежей 0.5.5 (то же самое происходит с 0.5.15, только собранного ручками)
> После запроса http://site.ru/nonexistent.(css|js|...) рабочий процесс падает с segfault, после этого запускается рабочий процесс с новым pid. В логах нгинкса ничего, в сислоге только nginx[pid]: segfault at ... error 6
> 
> # nginx.conf
> 
> user nginx nginx;
> 
> worker_processes 1;
> 
> error_log /var/log/nginx/error.log info;
> 
> events
> {
>   worker_connections 1024;
> 
>   use epoll;
> }
> 
> http
> {
>   client_header_buffer_size   1k;
>   client_header_timeout       3m;
>   client_body_timeout         3m;
>   default_type                application/octet-stream;
>   gzip                        on;
>   gzip_comp_level             5;
>   gzip_min_length             1100;
>   gzip_buffers                4 8k;
>   gzip_types                  text/plain application/x-javascript text/css;
>   gzip_proxied                off;
>   ignore_invalid_headers      on;
>   keepalive_timeout           0;
>   large_client_header_buffers 4 4k;
>   log_format                  main '$remote_addr $request $status';
>   output_buffers              1 32k;
>   postpone_output             1460;
>   sendfile                    on;
>   # send_lowat                12000;
>   send_timeout                3m;
>   tcp_nopush                  on;
>   tcp_nodelay                 on;
> 
>   include /etc/nginx/mime.types;
>   include /etc/nginx/vhosts/*.conf;
> }
> 
> # site.ru
> 
> server
> {
>   listen 192.168.0.1:80 default backlog=1024 rcvbuf=32768 sndbuf=32768;
>   server_name site.ru www.site.ru;
> 
>   root /var/lib/vhosts/site.ru/wwwroot;
> 
>   access_log /var/log/nginx/vhosts/site.ru/access.log main;
>   error_log  /var/log/nginx/vhosts/site.ru/error.log  info;
> 
>   error_page 403 /403.html;
>   error_page 404 /404.html;
>   error_page 500 502 503 504 /50x.html;
> 
>   location = /403.html { root /var/lib/vhosts/site.ru/errors; }
>   location = /404.html { root /var/lib/vhosts/site.ru/errors; }
>   location = /50x.html { root /var/lib/vhosts/site.ru/errors; }
> 
>   location /nginx-status
>   {
>     stub_status on;
>     access_log  off;
>     allow       127.0.0.1;
>     deny        all;
>   }
> 
>   location /
>   {
>     charset off;
>     expires off;
> 
>     client_max_body_size    64k;
>     client_body_buffer_size 64k;
>     client_body_temp_path   /var/tmp/nginx/client/site.ru;
> 
>     proxy_pass     http://127.0.0.1:80/;
>     proxy_redirect off;
> 
>     proxy_set_header Host            $host;
>     proxy_set_header X-Client-IP     $remote_addr;
>     proxy_set_header X-Forwarded-For $remote_addr;
>     proxy_set_header X-Real-IP       $remote_addr;
> 
>     proxy_connect_timeout 90;
>     proxy_send_timeout    90;
>     proxy_read_timeout    90;
>     # proxy_send_lowat    12000;
> 
>     proxy_buffer_size          4k;
>     proxy_buffers              4 32k;
>     proxy_busy_buffers_size    64k;
>     proxy_temp_file_write_size 64k;
>     proxy_temp_path            /var/tmp/nginx/proxy/site.ru;
>   }
> 
>   location ~* ^.+\.(css|js|gif|ico|jpg|jpeg|png)$
>   {
>     root       $document_root;
>                ^^^^^^^^^^^^^^^ если написать "/var/lib/vhosts/site.ru/wwwroot;",
>                                то все описанной выше проблемы не наблюдается.
>     access_log off;
>     expires    30d;
>   }
> }

Если в location нужно использовать тот же корень, что и для сервера,
то ничего указывать не нужно - он наследуется.

А segfault происходит из-за рекурсивного вызова: для определения
root вызывается переменная $document_root, которая опять вызывает
переменную $document_root и так далее. Нужно будет запретить её
использование  в таком контексте.


-- 
Игорь Сысоев
http://sysoev.ru





More information about the nginx-ru mailing list