Skip to content

Commit

Permalink
fix(proxy-wasm) free dispatch calls during resume edge-case
Browse files Browse the repository at this point in the history
Fix a Valgrind memory leak and an unrelated suppression.

Dispatch resume invoking on_request_headers for subsequent filters may
yield themselves (NGX_AGAIN). In this case, also ensure the dispatch
call is destroyed.

Fix the suppression for headers-more-nginx-module which can happen with
other stacktraces on builtin headers (e.g. Content-Length).
  • Loading branch information
thibaultcha committed Nov 9, 2023
1 parent 5dbf186 commit 5e02d5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ ngx_http_proxy_wasm_dispatch_destroy(ngx_http_proxy_wasm_dispatch_t *call)
sock = &call->sock;
rctx = call->rctx;

dd("enter");

ngx_wasm_socket_tcp_destroy(sock);

if (call->host.data) {
Expand Down Expand Up @@ -842,10 +844,7 @@ ngx_http_proxy_wasm_dispatch_resume_handler(ngx_wasm_socket_tcp_t *sock)
/* resume current step if unfinished */
rc = ngx_proxy_wasm_resume(pwexec->parent, pwexec->parent->phase,
step);
if (rc == NGX_AGAIN) {
goto done;

} else if (rc != NGX_OK) {
if (rc != NGX_OK && rc != NGX_AGAIN) {
goto error;
}

Expand Down
1 change: 1 addition & 0 deletions valgrind.suppress
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<headers-more-nginx-module: set_header_helper>
Memcheck:Cond
fun:ngx_http_set_header_helper
...
fun:ngx_http_headers_more_exec_cmd
fun:ngx_http_headers_more_filter
...
Expand Down

0 comments on commit 5e02d5f

Please sign in to comment.