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 18, 2023
1 parent 78ff646 commit ad259e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 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
3 changes: 1 addition & 2 deletions valgrind.suppress
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
<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
...
fun:main
}
{
<wasmer 3.1.1: parse>
Expand Down

0 comments on commit ad259e1

Please sign in to comment.