Skip to content

Commit

Permalink
bugfix: append new parameters to ngx_http_lua_ffi_balancer_set_curren…
Browse files Browse the repository at this point in the history
…t_peer at function end.

Avoid inserting new parameters in the middle of the function to prevent core
dumps when using old lua-resty-core with new lua-nginx-module.

Example stack trace:

```
Message: Process 1414245 (nginx) of user 1000 dumped core.

        Stack trace of thread 1414245:
        #0  0x00007ff596938285 __strlen_avx2 (libc.so.6 + 0x162285)
        openresty#1  0x00007ff596f623d2 lj_cf_ffi_string (libluajit-5.1.so.2 + 0x523d2)
        openresty#2  0x00007ff596f1bb4b lj_BC_FUNCC (libluajit-5.1.so.2 + 0xbb4b)
        openresty#3  0x00007ff596f74223 lua_pcall (libluajit-5.1.so.2 + 0x64223)
        openresty#4  0x00000000005044b7 n/a (/home/jiahao/work/org/lua-resty-core/work/nginx/sbin/nginx + 0x1044b7)
```
  • Loading branch information
jiahao committed Aug 1, 2024
1 parent 94b6934 commit c4257fe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ngx_http_lua_balancer.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,8 @@ ngx_http_lua_balancer_save_session(ngx_peer_connection_t *pc, void *data)
int
ngx_http_lua_ffi_balancer_set_current_peer(ngx_http_request_t *r,
const u_char *addr, size_t addr_len, int port,
const u_char *host, size_t host_len,
char **err)
char **err,
const u_char *host, size_t host_len)
{
ngx_url_t url;
ngx_http_lua_ctx_t *ctx;
Expand Down

0 comments on commit c4257fe

Please sign in to comment.