From: Eric Wong Date: Fri, 14 Feb 2025 09:38:55 +0000 (+0000) Subject: imap_searchqp: avoid occasional P::RD hint spew X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a624a643d69beef8ede8075afe6fd1ab874dfe25;p=thirdparty%2Fpublic-inbox.git imap_searchqp: avoid occasional P::RD hint spew It turns out Inline::C::Parser::RecDescent increments $::RD_HINT when Inline::C rebuilds are necessary, thus causing verbose log spew on bogus IMAP search queries in our own use of Parse::RecDescent. So, local-ize $::RD_HINT as we do with other $::RD_* vars to avoid Inline::C influencing our IMAP query parsing. Triggering the increment of $::RD_HINT via Inline::C::Parser::RecDescent may be achieved by forcing an Inline::C rebuild, such as clearing the contents of ~/.cache/public-inbox/inline-c/* or $ENV{PERL_INLINE_DIRECTORY}/* (but leaving one of those top-level directories to trigger Inline::C rebuilds. This bug mainly manifested in t/imap_searchqp.t under the `make check-run' test target which reuses existing processes to speed up tests, though it could manifest in real-world -imapd (and -netd) usage if the process spawning the daemon built Inline::C code. --- diff --git a/lib/PublicInbox/IMAPsearchqp.pm b/lib/PublicInbox/IMAPsearchqp.pm index d1a943e53..8136480ed 100644 --- a/lib/PublicInbox/IMAPsearchqp.pm +++ b/lib/PublicInbox/IMAPsearchqp.pm @@ -170,9 +170,6 @@ sub impossible { $$sql .= ' AND num < 0'; } -# XXX not sure suppessing RD_* is needed here, but t/imap_searchqp.t -# sporadically fails -local ($::RD_ERRORS, $::RD_WARN); my $prd = Parse::RecDescent->new(<<'EOG'); { my $q = $PublicInbox::IMAPsearchqp::q; } @@ -281,8 +278,8 @@ sub parse { my ($imap, $query) = @_; my $sql = ''; %$q = (sql => \$sql, imap => $imap); # imap = PublicInbox::IMAP obj - # XXX not always effective for t/imap_searchqp.t - local ($::RD_ERRORS, $::RD_WARN); + # Inline::C::Parser::RecDescent may set RD_HINT + local ($::RD_ERRORS, $::RD_WARN, $::RD_HINT); my $res = eval { $prd->search_key(uc($query)) }; return $@ if $@ && $@ =~ /\A(?:BAD|NO) /; return 'BAD unexpected result' if !$res || $res != $q; diff --git a/t/imap_searchqp.t b/t/imap_searchqp.t index 95cdd2017..13ee22346 100644 --- a/t/imap_searchqp.t +++ b/t/imap_searchqp.t @@ -39,12 +39,7 @@ like($q, qr/\ANO \[/, 'bad charset rejected'); open STDERR, '>&', $olderr; seek $tmperr, 0, SEEK_SET; read($tmperr, my $buf, -s $tmperr); - is($buf, '', 'nothing spewed to STDERR on bad query') or warn <<'EOM'; -FIXME: this sometimes fails despite setting $::RD_ERRORS + $::RD_WARN to -undef in PublicInbox::IMAPsearchqp::parse and I don't understand why. -It usually suceeds. Let us know if you can help us understand this -occasional failure at meta@public-inbox.org -EOM + is $buf, '', 'nothing spewed to STDERR on bad query'; } like($q, qr/\ABAD /, 'bad charset rejected');