# Segfault in nginx 1.0.5

**URL:** <https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421>\
**Category:** NGINX\
**Created:** [August 8, 2011, 3:51am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421 "2011-08-08T03:51:01Z")\
**Posts on this page:** 8\
**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:** [August 8, 2011, 3:51am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/1 "2011-08-08T03:51:01Z")

</div>

Hi guys,

I’m seeing a small segfault in 1.0.5

It is strage there is something triggering it as it happens at the same  
time every night. It isn’t triggered by crontab as I have nothing that  
runs at that time.  
I’m running the keepalive patch (however this was happening before I  
installed it).

Anyway here is the backtrace

#0 0x00007fd02a58cc9e in memcpy () from /lib/libc.so.6  
#1 0x000000000049fb4c in ngx\_http\_proxy\_create\_request (r=0x19f3d80) at  
src/http/modules/ngx\_http\_proxy\_module.c:1021  
#2 0x0000000000470a2b in ngx\_http\_upstream\_init\_request (r=0x19f3d80)  
at src/http/ngx\_http\_upstream.c:497  
#3 0x0000000000470868 in ngx\_http\_upstream\_init (r=0x19f3d80) at  
src/http/ngx\_http\_upstream.c:438  
#4 0x0000000000466f5c in ngx\_http\_read\_client\_request\_body  
(r=0x19f3d80, post\_handler=0x470775 \<ngx\_http\_upstream\_init\>)  
at src/http/ngx\_http\_request\_body.c:58  
#5 0x000000000049eb49 in ngx\_http\_proxy\_handler (r=0x19f3d80) at  
src/http/modules/ngx\_http\_proxy\_module.c:655  
#6 0x000000000044f19b in ngx\_http\_core\_content\_phase (r=0x19f3d80,  
ph=0x1a07a60) at src/http/ngx\_http\_core\_module.c:1339  
#7 0x000000000044ddc4 in ngx\_http\_core\_run\_phases (r=0x19f3d80) at  
src/http/ngx\_http\_core\_module.c:837  
#8 0x000000000044dd3b in ngx\_http\_handler (r=0x19f3d80) at  
src/http/ngx\_http\_core\_module.c:820  
#9 0x000000000045159d in ngx\_http\_internal\_redirect (r=0x19f3d80,  
uri=0x7fff40c440f0, args=0x7fff40c440e0)  
at src/http/ngx\_http\_core\_module.c:2347  
#10 0x0000000000457836 in ngx\_http\_send\_error\_page (r=0x19f3d80,  
err\_page=0x19b3168) at src/http/ngx\_http\_special\_response.c:560  
#11 0x0000000000457430 in ngx\_http\_special\_response\_handler  
(r=0x19f3d80, error=400) at src/http/ngx\_http\_special\_response.c:402  
#12 0x000000000045c31d in ngx\_http\_finalize\_request (r=0x19f3d80,  
rc=400) at src/http/ngx\_http\_request.c:1944  
#13 0x0000000000459bfe in ngx\_http\_process\_request\_line  
(rev=0x7fd029684de0) at src/http/ngx\_http\_request.c:907  
#14 0x0000000000458ebe in ngx\_http\_init\_request (rev=0x7fd029684de0) at  
src/http/ngx\_http\_request.c:521  
#15 0x00000000004368e1 in ngx\_event\_process\_posted (cycle=0x18d4d60,  
posted=0x6de408) at src/event/ngx\_event\_posted.c:39  
#16 0x000000000043467c in ngx\_process\_events\_and\_timers  
(cycle=0x18d4d60) at src/event/ngx\_event.c:272  
#17 0x000000000044165d in ngx\_worker\_process\_cycle (cycle=0x18d4d60,  
data=0x0) at src/os/unix/ngx\_process\_cycle.c:800  
#18 0x000000000043e146 in ngx\_spawn\_process (cycle=0x18d4d60,  
proc=0x4414a1 \<ngx\_worker\_process\_cycle\>, data=0x0,  
name=0x4b5583 “worker process”, respawn=-3) at  
src/os/unix/ngx\_process.c:196  
#19 0x00000000004404b4 in ngx\_start\_worker\_processes (cycle=0x18d4d60,  
n=14, type=-3) at src/os/unix/ngx\_process\_cycle.c:360  
#20 0x000000000043fb0c in ngx\_master\_process\_cycle (cycle=0x18d4d60) at  
src/os/unix/ngx\_process\_cycle.c:136  
#21 0x000000000040fd89 in main (argc=1, argv=0x7fff40c448b8) at  
src/core/nginx.c:405

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [August 8, 2011, 8:41am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/2 "2011-08-08T08:41:46Z")

</div>

Hello!

On Mon, Aug 08, 2011 at 01:50:12AM +0000, Kingsley F. wrote:

> #9 0x000000000045159d in ngx\_http\_internal\_redirect (r=0x19f3d80,  
> uri=0x7fff40c440f0, args=0x7fff40c440e0)  
> at src/http/ngx\_http\_core\_module.c:2347  
> #10 0x0000000000457836 in ngx\_http\_send\_error\_page (r=0x19f3d80,  
> err\_page=0x19b3168) at src/http/ngx\_http\_special\_response.c:560  
> #11 0x0000000000457430 in ngx\_http\_special\_response\_handler (r=0x19f3d80,  
> error=400) at src/http/ngx\_http\_special\_response.c:402  
> #12 0x000000000045c31d in ngx\_http\_finalize\_request (r=0x19f3d80, rc=400) at  
> src/http/ngx\_http\_request.c:1944  
> #13 0x0000000000459bfe in ngx\_http\_process\_request\_line (rev=0x7fd029684de0) at  
> src/http/ngx\_http\_request.c:907

Could you please show your config? It looks like you are using  
something like

```
error_page 400 @fallback;

location @fallback {
    proxy_pass ...
}

```

in it.

This is obviously a bug, though you may easily avoid triggering it  
by not intercepting error page 400.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [August 8, 2011, 8:44am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/3 "2011-08-08T08:44:14Z")

</div>

Would something like this do it?

```
            error_page 403 404 /error.html;

            location /error.html {
                    set $args "";
                    proxy_pass http://squid/;
                    internal;
            }

```

Kingsley

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [August 8, 2011, 8:47am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/4 "2011-08-08T08:47:58Z")

</div>

Wait someone put one of these in another file

error\_page 400 403 404 /error.html;

```
            location /error.html {
                    set $args "";
                    proxy_pass http://squid/;
                    internal;
            }

```

I’m assuming that could be it, if it is ill remove it

Kingsley

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [August 8, 2011, 8:49am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/5 "2011-08-08T08:49:12Z")

</div>

Hello!

On Mon, Aug 08, 2011 at 06:43:35AM +0000, Kingsley F. wrote:

> Would something like this do it?
> 
> ```
> error_page 403 404 /error.html;
> 
> ```

This problem is specific to error\_page 400, as 400 means “bad  
request” and request may not have some required parts set (due to  
being actually bad).

Maxim D.

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [August 8, 2011, 8:50am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/6 "2011-08-08T08:50:27Z")

</div>

Thanks Maxim,

A++ for the help (and the keepalive patch)

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [August 8, 2011, 9:41am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/7 "2011-08-08T09:41:47Z")

</div>

Hi,

Am 08.08.2011 08:48, schrieb Maxim D.:

> This problem is specific to error\_page 400, as 400 means “bad  
> request” and request may not have some required parts set (due to  
> being actually bad).

but in this case an error or warning or whatsoever would be better  
than just a segfault, right? 😉

Don’t want to bug at it, i just think that catching such config  
problems would be good for the future (and as i’m not a coder  
in general, i cannot fix it by myself…).

Regards,  
Sven

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [August 8, 2011, 11:12am UTC](https://www.ruby-forum.com/t/segfault-in-nginx-1-0-5/210421/8 "2011-08-08T11:12:55Z")

</div>

Hello!

On Mon, Aug 08, 2011 at 09:41:11AM +0200, Sven ‘Darkman’ Michels wrote:

> Don’t want to bug at it, i just think that catching such config  
> problems would be good for the future (and as i’m not a coder  
> in general, i cannot fix it by myself…).

I specifically outlined in my original reply that this _is_ a bug  
(and it obviously needs fixing).

Maxim D.
