user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] imap_searchqp: avoid occasional P::RD hint spew
@ 2025-02-14  9:38 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2025-02-14  9:38 UTC (permalink / raw)
  To: meta

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.
---
 Noticed while working on some Inline::C stuff which
 I may end up abandoning...

 lib/PublicInbox/IMAPsearchqp.pm | 7 ++-----
 t/imap_searchqp.t               | 7 +------
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/lib/PublicInbox/IMAPsearchqp.pm b/lib/PublicInbox/IMAPsearchqp.pm
index d1a943e5..8136480e 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');
 <nocheck>
 { 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 95cdd201..13ee2234 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');

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-14  9:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14  9:38 [PATCH] imap_searchqp: avoid occasional P::RD hint spew Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).