From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 16AC61FF14F for ; Wed, 17 Jun 2026 14:29:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6196033564; Wed, 17 Jun 2026 14:29:25 +0200 (CEST) From: Kefu Chai To: pve-devel@lists.proxmox.com Subject: [PATCH v4 http-server 0/1] fix pveproxy OOM in websocket and spice proxy handlers Date: Wed, 17 Jun 2026 20:29:04 +0800 Message-ID: <20260617122905.3822836-1-k.chai@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1781699303932 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.281 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com,anyevent.pm] Message-ID-Hash: D2HDXBR4CYTBBOROASFTZTRT6OVSK7RE X-Message-ID-Hash: D2HDXBR4CYTBBOROASFTZTRT6OVSK7RE X-MailFrom: k.chai@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: see v2's cover letter [1] for the problem description and the approach. Changes since v3: * fix a reference-cycle leak in apply_read_backpressure(): it now reads the resume callback off the source handle instead of taking it as an argument, so the proxy readers no longer pass themselves in. a reader that references its own variable is a self-referential closure, an uncollectable cycle that pinned $reqstate on every disconnect. this also lets response_stream() drop the manual `$on_read = undef` it kept only to break that same cycle. * split the drain and the teardown in handle_proxy_eof() into separate eval blocks. the websocket reader dies on a malformed trailing frame left in rbuf, and v3's single eval let that die skip client_do_disconnect() and leak the connection. * deduplicate the on_error handlers into a shared handle_proxy_error(); the three proxy on_error bodies were copy-paste of each other. checked locally with an out-of-tree synthetic AnyEvent setup (not part of this series): reverting the eval split leaks a connection on a reader die, and reverting the reference-cycle fix leaves $reqstate uncollected after disconnect. [1] https://lore.proxmox.com/pve-devel/20260413125650.2569621-1-k.chai@proxmox.com/ Kefu Chai (1): fix #7483: apiserver: add backpressure to proxy handlers src/PVE/APIServer/AnyEvent.pm | 197 +++++++++++++++++++++++----------- 1 file changed, 135 insertions(+), 62 deletions(-) -- 2.47.3