Skip to content

fix(server): worker-shell release double-free when a handler captures $server - #141

Merged
EdmondDantes merged 1 commit into
mainfrom
fix/worker-shell-release-double-free
Jul 29, 2026
Merged

fix(server): worker-shell release double-free when a handler captures $server#141
EdmondDantes merged 1 commit into
mainfrom
fix/worker-shell-release-double-free

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

A WebSocket handler that captures $server is transferred per worker; the captured server and the transit shell xlat-dedup to the same object. http_server_release_worker_shell freed config, each closure and the transit in separate transferred-zval releases (separate visited sets), so on a shutdown before the closure LOADed the shared object was freed twice — double-free under valgrind/ASan, hard crash on the Windows debug heap. Now gathers the roots and makes ONE batched release. Needs the async batched-release API (php-src + php-async PRs). Regression: test 067 (setWorkers(2), handler captures $server, a send parked at stop()) — rc134 without the fix, valgrind-clean with it.

…-free)

A WebSocket handler that captures $server is transferred per worker; the captured
server and the transit shell xlat-dedup to the same object. http_server_release_
worker_shell freed config, each handler closure, and the transit in separate
transferred-zval releases — separate visited sets — so on a shutdown before the
closure LOADed, the shared object was freed twice (double-free under valgrind/ASan;
a hard crash on the Windows debug heap).

Gather the roots and make ONE batched release
(ZEND_ASYNC_THREAD_RELEASE_TRANSFERRED_ZVALS). Requires the async batched-release
API. Regression test 067 (setWorkers(2), handler captures $server, a send parked
at stop()) fails rc134 without the fix.
@EdmondDantes
EdmondDantes force-pushed the fix/worker-shell-release-double-free branch from fca4430 to 573cf58 Compare July 28, 2026 21:25
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Coverage

Total lines: 81.94% → 81.94% (-0.00 pp)

File Baseline Current Δ Touched
src/core/http_connection.c 75.45% 75.26% -0.19 pp
src/core/http_connection_tls.c 73.74% 73.46% -0.28 pp
src/http3/http3_callbacks.c 83.65% 83.98% +0.33 pp
src/http3/http3_static_response.c 75.11% 76.37% +1.27 pp
src/http_server_class.c 73.80% 73.77% -0.03 pp
src/http_server_config.c 92.45% 92.39% -0.06 pp
src/websocket/ws_session.c 89.94% 89.76% -0.19 pp

@EdmondDantes
EdmondDantes merged commit 9b8d88d into main Jul 29, 2026
8 checks passed
@EdmondDantes
EdmondDantes deleted the fix/worker-shell-release-double-free branch July 29, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant