Skip to content

balancer_by_lua_file segmentation fault since commit 246ec8a #1572

@DejanPelzel

Description

@DejanPelzel

Hello,

We are using a long list of upstreams using balancer_by_lua_file. The total number is around 700. Since commit 246ec8a this is causing segmentation faults when starting nginx. Reducing the number of upstreams to 40 or less usually helps, but not always, it seems a random combination of the zone size and upstream count etc.

We tested this on nginx versions Nginx version 1.15.12 until 1.17.2 and the segmentation fault happens consistently. The content of balancer_by_lua_file does not affect the results and the file can be blank for easier troubleshooting.

An example list goes like this:

upstream dynamic_proxy_upstream1 {
	server 0.0.0.1;
	zone dynamic_upstream1 256k;
	balancer_by_lua_file /etc/nginx/balancer.lua;
	keepalive_timeout 120s;
	keepalive 100;
}

upstream dynamic_proxy_upstream2 {
	server 0.0.0.1;
	zone dynamic_upstream2 256k;
	balancer_by_lua_file /etc/nginx/balancer.lua;
	keepalive_timeout 120s;
	keepalive 100;
}

upstream dynamic_proxy_upstream3 {
	server 0.0.0.1;
	zone dynamic_upstream3 256k;
	balancer_by_lua_file /etc/nginx/balancer.lua;
	keepalive_timeout 120s;
	keepalive 100;
}

etc...

I've captured a coredump:

Thread 1: status = VgTs_Runnable (lwpid 9369)
==9369==    at 0x2BCDA2: ngx_http_lua_gen_file_cache_key_helper (ngx_http_lua_cache.c:383)
==9369==    by 0x2BCDA2: ngx_http_lua_gen_file_cache_key (ngx_http_lua_cache.c:400)
==9369==    by 0x2DC865: ngx_http_lua_balancer_by_lua (ngx_http_lua_balancer.c:158)
==9369==    by 0x1D3B43: ngx_conf_handler (ngx_conf_file.c:463)
==9369==    by 0x1D3B43: ngx_conf_parse (ngx_conf_file.c:319)
==9369==    by 0x214911: ngx_http_upstream (ngx_http_upstream.c:5795)
==9369==    by 0x1D3B43: ngx_conf_handler (ngx_conf_file.c:463)
==9369==    by 0x1D3B43: ngx_conf_parse (ngx_conf_file.c:319)
==9369==    by 0x1D3F15: ngx_conf_include (ngx_conf_file.c:841)
==9369==    by 0x1D3B43: ngx_conf_handler (ngx_conf_file.c:463)
==9369==    by 0x1D3B43: ngx_conf_parse (ngx_conf_file.c:319)
==9369==    by 0x1F3A45: ngx_http_block (ngx_http.c:237)
==9369==    by 0x1D3B43: ngx_conf_handler (ngx_conf_file.c:463)
==9369==    by 0x1D3B43: ngx_conf_parse (ngx_conf_file.c:319)
==9369==    by 0x1D0E59: ngx_init_cycle (ngx_cycle.c:275)
==9369==    by 0x1BF7BE: main (nginx.c:291)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions