Skip to content

Commit ebf9719

Browse files
committed
bugfix: SIGSEGV in receiveuntil __gc on aborted multipart upload.
read_error_retval_handler calls finalize_read_part directly when the receiveuntil iterator's recv errors. That clears u->buf_in but leaves cp->upstream live with cp->state > 0. Later GC fires cleanup_compiled_pattern -> read_prepare, which derefs the now-NULL u->buf_in. Mirror tcp_finalize's cp->upstream = NULL detach so __gc's existing `if (u != NULL)` guard short-circuits.
1 parent 41ed26b commit ebf9719

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/ngx_http_lua_socket_tcp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,6 +4203,12 @@ ngx_http_lua_socket_tcp_finalize_read_part(ngx_http_request_t *r,
42034203
ngx_memzero(&u->buffer, sizeof(ngx_buf_t));
42044204
}
42054205

4206+
/* mirror tcp_finalize: detach cp so its __gc is safe */
4207+
if (u->input_filter_ctx != NULL && u->input_filter_ctx != u) {
4208+
((ngx_http_lua_socket_compiled_pattern_t *)
4209+
u->input_filter_ctx)->upstream = NULL;
4210+
}
4211+
42064212
if (u->raw_downstream || u->body_downstream) {
42074213
if (r->connection->read->timer_set) {
42084214
ngx_del_timer(r->connection->read);

0 commit comments

Comments
 (0)