kernel: trap divide error

Maxim Dounin mdounin at mdounin.ru
Mon Aug 25 00:10:08 MSD 2008


Hello!

On Sun, Aug 24, 2008 at 01:03:03PM +0200, Olivier Bonvalet wrote:

> Hello,
>
> I use NginX 0.6.32-1 (the Debian sid package, recompiled for Debian  
> Etch) in a 64bit environnement (about 25M hits per day, per server).
> NginX is used to serve static contents, and send other queries to an  
> Apache server.
>
> I have a lot of errors like this in my logs :
> Aug 24 01:48:13 fa20 kernel: nginx[10825] trap divide error ip:43bce1  
> sp:7fff4cd38160 error:0 in nginx[400000+6c000]
> Aug 24 01:48:18 fa20 kernel: nginx[10826] trap divide error ip:43bce1  
> sp:7fff4cd38160 error:0 in nginx[400000+6c000]
> Aug 24 01:48:48 fa20 kernel: nginx[11046] trap divide error ip:43bce1  
> sp:7fff4cd38160 error:0 in nginx[400000+6c000]
> Aug 24 01:49:01 fa20 kernel: nginx[11093] trap divide error ip:43bce1  
> sp:7fff4cd38160 error:0 in nginx[400000+6c000]
>
> So I would like to know if it is a "kernel problem", an NginX problem,  
> or simply a problem in my NginX configuration.
>
> From logs, errors started when I modify upstream configuration. For now  
> I use this :
>    upstream clusterweb {
>        server 127.0.0.1:81 weight=4 max_fails=0 fail_timeout=10s;
>        server 127.0.0.2:82    backup;
>    }
>    upstream clusterwebtest {
>        server 127.0.0.1:81 max_fails=0 fail_timeout=10s;

The max_fails=0 known to be broken in 0.6.* (and 0.7.*) since 
0.6.6.  I've sent a patch to Igor some time ago, but it looks like 
he forgot it.

Don't use max_fails=0 or try the attached patch.

Maxim Dounin
-------------- next part --------------
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1219608451 -14400
# Node ID 1778c5186281f66061336c170477e316c0fafd4f
# Parent  15c4ba3bc2fad0e15329058ac6f18c5cc879510e
Don't divide by zero if max_fails set to 0.

diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -645,7 +645,9 @@ ngx_http_upstream_free_round_robin_peer(
         peer->fails++;
         peer->accessed = now;
 
-        peer->current_weight -= peer->weight / peer->max_fails;
+        if (peer->max_fails > 0) {
+            peer->current_weight -= peer->weight / peer->max_fails;
+        }
 
         ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
                        "free rr peer failed: %ui %i",


More information about the nginx mailing list