From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1B4721F49B for ; Mon, 30 Mar 2020 18:30:10 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] qspawn: capture errors from parse_hdr callback Date: Mon, 30 Mar 2020 18:30:08 +0000 Message-Id: <20200330183009.25541-2-e@yhbt.net> In-Reply-To: <20200330183009.25541-1-e@yhbt.net> References: <20200330183009.25541-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: User-supplied callbacks may fail, so capture the error instead of propagating it up the stack into the public-inbox-httpd event loop. --- lib/PublicInbox/Qspawn.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm index 34b6912f..aebcb1f7 100644 --- a/lib/PublicInbox/Qspawn.pm +++ b/lib/PublicInbox/Qspawn.pm @@ -234,7 +234,11 @@ sub rd_hdr ($) { length($$hdr_buf)); if (defined($r)) { $total_rd += $r; - $ret = $ph_cb->($total_rd, $hdr_buf, $ph_arg); + eval { $ret = $ph_cb->($total_rd, $hdr_buf, $ph_arg) }; + if ($@) { + log_err($self->{psgi_env}, "parse_hdr: $@"); + $ret = [ 500, [], [ "Internal error\n" ] ]; + } } else { # caller should notify us when it's ready: return if $! == EAGAIN;