# Error\_page, try\_files, internal redirect ends up in SIGSEGV

**URL:** <https://www.ruby-forum.com/t/error-page-try-files-internal-redirect-ends-up-in-sigsegv/219121>\
**Category:** NGINX\
**Created:** [April 21, 2012, 2:48am UTC](https://www.ruby-forum.com/t/error-page-try-files-internal-redirect-ends-up-in-sigsegv/219121 "2012-04-21T02:48:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 21, 2012, 2:48am UTC](https://www.ruby-forum.com/t/error-page-try-files-internal-redirect-ends-up-in-sigsegv/219121/1 "2012-04-21T02:48:36Z")

</div>

Hello,

I’m facing a SIGSEGV when trying to setup a custom error page using  
the following (shortened for the sake of debugging) configuration.

/etc/nginx/sites-available/example.com:  
server {  
listen 80;  
server\_name [example.com](http://example.com);

access\_log /var/log/nginx/example.com\_access.log;  
error\_log /var/log/nginx/example.com\_error.log debug;

root /var/www;

error\_page 404 @404;

location @404 {  
try\_files /404.html =404;  
}

location / {  
try\_files $uri $uri/ /index.php;  
}

location ~ .php$ {  
try\_files $uri =404;

# include php.conf;

# fastcgi\_pass unix:/var/run/php5-fpm/www.sock;

}  
}

The intent is to test whether $uri exists as a file, then a directory,  
then if it doesn’t exist defer to index.php if present. When index.php  
doesn’t exist, use the custom 404 page.

/var/www content:  
/var/www/index.html  
/var/www/404.html

There is no /var/www/index.php and I’m expecting my custom 404.html  
page to be served.

Here is a debug log when accessing [http://example.com/foo.txt](http://example.com/foo.txt)

2012/04/21 02:38:41 [debug] 18030#0: \*71 event timer del: 35: 3528919376  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 0  
2012/04/21 02:38:41 [debug] 18030#0: \*71 rewrite phase: 1  
2012/04/21 02:38:41 [debug] 18030#0: \*71 test location: “/”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 test location: ~ “.php$”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 using configuration “/”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 http cl:-1 max:524288  
2012/04/21 02:38:41 [debug] 18030#0: \*71 rewrite phase: 3  
2012/04/21 02:38:41 [debug] 18030#0: \*71 post rewrite phase: 4  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 5  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 6  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 7  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 8  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 9  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 10  
2012/04/21 02:38:41 [debug] 18030#0: \*71 post access phase: 11  
2012/04/21 02:38:41 [debug] 18030#0: \*71 try files phase: 12  
2012/04/21 02:38:41 [debug] 18030#0: \*71 http script var: “/foo.txt”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 trying to use file:  
“/foo.txt” “/var/www/foo.txt”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 add cleanup: 09D15FA8  
2012/04/21 02:38:41 [debug] 18030#0: \*71 malloc: 09C2E528:88  
2012/04/21 02:38:41 [debug] 18030#0: \*71 malloc: 09C2E5B0:55  
2012/04/21 02:38:41 [debug] 18030#0: \*71 cached open file:  
/var/www/foo.txt, fd:-1, c:0, e:2, u:1  
2012/04/21 02:38:41 [debug] 18030#0: \*71 http script var: “/foo.txt”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 trying to use dir: “/foo.txt”  
“/var/www/foo.txt”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 add cleanup: 09D15FC4  
2012/04/21 02:38:41 [debug] 18030#0: \*71 cached open file:  
/var/www/foo.txt, fd:-1, c:0, e:2, u:2  
2012/04/21 02:38:41 [debug] 18030#0: \*71 trying to use file:  
“/index.php” “/var/www/index.php”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 internal redirect:  
“/index.php?”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 rewrite phase: 1  
2012/04/21 02:38:41 [debug] 18030#0: \*71 test location: “/”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 test location: ~ “.php$”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 using configuration “.php$”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 http cl:-1 max:524288  
2012/04/21 02:38:41 [debug] 18030#0: \*71 rewrite phase: 3  
2012/04/21 02:38:41 [debug] 18030#0: \*71 post rewrite phase: 4  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 5  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 6  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 7  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 8  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 9  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 10  
2012/04/21 02:38:41 [debug] 18030#0: \*71 post access phase: 11  
2012/04/21 02:38:41 [debug] 18030#0: \*71 try files phase: 12  
2012/04/21 02:38:41 [debug] 18030#0: \*71 http script var: “/index.php”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 trying to use file:  
“/index.php” “/var/www/index.php”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 add cleanup: 09D1602C  
2012/04/21 02:38:41 [debug] 18030#0: \*71 malloc: 09C2E5F0:88  
2012/04/21 02:38:41 [debug] 18030#0: \*71 malloc: 09C2E650:57  
2012/04/21 02:38:41 [debug] 18030#0: \*71 cached open file:  
/var/www/index.php, fd:-1, c:0, e:2, u:1  
2012/04/21 02:38:41 [debug] 18030#0: \*71 trying to use file: “=404”  
“/var/www=404”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 http finalize request: 404,  
“/index.php?” a:1, c:2  
2012/04/21 02:38:41 [debug] 18030#0: \*71 http special response: 404,  
“/index.php?”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 test location: “@404”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 using location: @404  
“/index.php?”  
2012/04/21 02:38:41 [debug] 18030#0: \*71 rewrite phase: 3  
2012/04/21 02:38:41 [debug] 18030#0: \*71 post rewrite phase: 4  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 5  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 6  
2012/04/21 02:38:41 [debug] 18030#0: \*71 generic phase: 7  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 8  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 9  
2012/04/21 02:38:41 [debug] 18030#0: \*71 access phase: 10  
2012/04/21 02:38:41 [debug] 18030#0: \*71 post access phase: 11  
2012/04/21 02:38:41 [debug] 18030#0: \*71 try files phase: 12

At which point nginx crashes, /var/log/nginx/error.log:  
2012/04/21 02:38:41 [alert] 17786#0: worker process 18030 exited on  
signal 11

# nginx -V

nginx version: nginx/1.1.19  
TLS SNI support enabled  
configure arguments: --prefix=/etc/nginx  
–conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log  
–http-client-body-temp-path=/var/lib/nginx/body  
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi  
–http-log-path=/var/log/nginx/access.log  
–http-proxy-temp-path=/var/lib/nginx/proxy  
–http-scgi-temp-path=/var/lib/nginx/scgi  
–http-uwsgi-temp-path=/var/lib/nginx/uwsgi  
–lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid  
–with-debug --with-http\_addition\_module --with-http\_dav\_module  
–with-http\_geoip\_module --with-http\_gzip\_static\_module  
–with-http\_image\_filter\_module --with-http\_realip\_module  
–with-http\_stub\_status\_module --with-http\_ssl\_module  
–with-http\_sub\_module --with-http\_xslt\_module --with-ipv6  
–with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl  
–with-mail --with-mail\_ssl\_module  
–add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-auth-pam  
–add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-echo  
–add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-upstream-fair  
–add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-dav-ext-module

I’m using nginx 1.1.19-1~bpo60+1 package from Debian squeeze backports.

Any idea please?  
Is there anything else I can report?

Gregory

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 21, 2012, 5:29am UTC](https://www.ruby-forum.com/t/error-page-try-files-internal-redirect-ends-up-in-sigsegv/219121/2 "2012-04-21T05:29:01Z")

</div>

On Sat, Apr 21, 2012 at 02:47:23AM +0200, Grgory P. wrote:

> I’m facing a SIGSEGV when trying to setup a custom error page using  
> the following (shortened for the sake of debugging) configuration.

It’s been fixed already:  
[http://trac.nginx.org/nginx/changeset/4601/nginx](http://trac.nginx.org/nginx/changeset/4601/nginx)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 21, 2012, 9:56am UTC](https://www.ruby-forum.com/t/error-page-try-files-internal-redirect-ends-up-in-sigsegv/219121/3 "2012-04-21T09:56:59Z")

</div>

On Sat, Apr 21, 2012 at 5:28 AM, Ruslan E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Sat, Apr 21, 2012 at 02:47:23AM +0200, Grgory P. wrote:
> 
> > I’m facing a SIGSEGV when trying to setup a custom error page using  
> > the following (shortened for the sake of debugging) configuration.
> 
> It’s been fixed already:  
> [http://trac.nginx.org/nginx/changeset/4601/nginx](http://trac.nginx.org/nginx/changeset/4601/nginx)

Hi there!

Thank you for the answer. At least I managed to conduct my first nginx  
debug session 🙂

Looking forward nginx 1.2.0 then.

Regards,  
Gregory
