[alibaba/tengine]使用 master 最新代码 2.2.0 会出现内存溢出问题

2024-07-10 546 views
8

使用 master 最新代码 2.2.0 会出现内存溢出问题。core 文件分析的调用栈如下:

(gdb) backtrace 
#0  0x0000003f826891ab in memcpy () from /lib64/libc.so.6
#1  0x0000000000492e38 in ngx_http_upstream_addr_variable (r=0x2477980, v=0x2478518, 
    data=<value optimized out>) at src/http/ngx_http_upstream.c:4976
#2  0x000000000048ca23 in ngx_http_get_indexed_variable (r=0x2477980, index=<value optimized out>)
    at src/http/ngx_http_variables.c:600
#3  0x000000000048a63e in ngx_http_log_variable_getlen (r=<value optimized out>, 
    data=<value optimized out>) at src/http/modules/ngx_http_log_module.c:978
#4  0x000000000048abb3 in ngx_http_log_handler (r=0x2477980)
    at src/http/modules/ngx_http_log_module.c:300
#5  0x0000000000480f1a in ngx_http_log_request (r=0x2477980) at src/http/ngx_http_request.c:3551
#6  0x00000000004815dd in ngx_http_free_request (r=0x2477980, rc=0) at src/http/ngx_http_request.c:3498
#7  0x000000000048170f in ngx_http_close_request (r=0x2477980, rc=0) at src/http/ngx_http_request.c:3445
#8  0x0000000000483378 in ngx_http_finalize_connection (r=0x2477980) at src/http/ngx_http_request.c:2580
#9  0x00000000004837a8 in ngx_http_finalize_request (r=<value optimized out>, rc=<value optimized out>)
    at src/http/ngx_http_request.c:2462
#10 0x0000000000494536 in ngx_http_upstream_finalize_request (r=0x2477980, u=0x20b6620, rc=0)
    at src/http/ngx_http_upstream.c:4159
#11 0x000000000049514d in ngx_http_upstream_process_request (r=0x2477980, u=0x20b6620)
    at src/http/ngx_http_upstream.c:3727
#12 0x0000000000496620 in ngx_http_upstream_process_upstream (r=0x2477980, u=0x20b6620)
    at src/http/ngx_http_upstream.c:3660
#13 0x00000000004975f5 in ngx_http_upstream_send_response (r=0x2477980, u=0x20b6620)
    at src/http/ngx_http_upstream.c:3023
#14 ngx_http_upstream_process_header (r=0x2477980, u=0x20b6620) at src/http/ngx_http_upstream.c:2218
#15 0x0000000000494b67 in ngx_http_upstream_handler (ev=<value optimized out>)
    at src/http/ngx_http_upstream.c:1141
#16 0x000000000046cc79 in ngx_epoll_process_events (cycle=<value optimized out>, 
    timer=<value optimized out>, flags=<value optimized out>)
    at src/event/modules/ngx_epoll_module.c:822
#17 0x0000000000464b4f in ngx_process_events_and_timers (cycle=0x1662ac0) at src/event/ngx_event.c:261
#18 0x000000000046b8ae in ngx_worker_process_cycle (cycle=0x1662ac0, data=<value optimized out>)
    at src/os/unix/ngx_process_cycle.c:804
#19 0x0000000000468fca in ngx_spawn_process (cycle=0x1662ac0, proc=0x46b7cf <ngx_worker_process_cycle>, 
    data=0x0, name=0x68e0bf "worker process", respawn=-3) at src/os/unix/ngx_process.c:198
#20 0x000000000046acb6 in ngx_start_worker_processes (cycle=0x1662ac0, n=16, type=-3)
    at src/os/unix/ngx_process_cycle.c:384
#21 0x000000000046bdfc in ngx_master_process_cycle (cycle=0x1662ac0)
    at src/os/unix/ngx_process_cycle.c:132
#22 0x000000000044dc02 in main (argc=<value optimized out>, argv=<value optimized out>)
    at src/core/nginx.c:426

内核中也有 page allocation failure 的报错。

回答

3

尝试输出一下 frame 1的一些参数信息:

            p = ngx_cpymem(p, state[i].peer->data, state[i].peer->len);

(gdb) p p
(gdb) p state[i].peer->data
(gdb) p state[i].peer->len

另外提供一下configure参数和nginx.conf配置,如果可以的话提供一下复现方法

4

继续调查了一下,内存溢出的问题是引起的其他模块引起的。