user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 13/13] spawnpp: raise exception on E2BIG errors
  2021-02-08  9:05  6% [PATCH 00/13] lei approxidate, startup fix, --alert Eric Wong
@ 2021-02-08  9:05  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-02-08  9:05 UTC (permalink / raw)
  To: meta

This matches the Inline::C version, and lets us test
argv overflow with $search->query_argv_to_string;
---
 lib/PublicInbox/SpawnPP.pm | 23 +++++++++++++++++++----
 t/search.t                 |  7 +++++++
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/SpawnPP.pm b/lib/PublicInbox/SpawnPP.pm
index 2c5edef6..6d7e2c34 100644
--- a/lib/PublicInbox/SpawnPP.pm
+++ b/lib/PublicInbox/SpawnPP.pm
@@ -16,13 +16,19 @@ sub pi_fork_exec ($$$$$$$) {
 	$set->fillset or die "fillset failed: $!";
 	sigprocmask(SIG_SETMASK, $set, $old) or die "can't block signals: $!";
 	my $syserr;
+	pipe(my ($r, $w));
 	my $pid = fork;
 	unless (defined $pid) { # compat with Inline::C version
 		$syserr = $!;
 		$pid = -1;
 	}
 	if ($pid == 0) {
-		$SIG{__DIE__} = sub { warn @_; _exit 1 };
+		close $r;
+		$SIG{__DIE__} = sub {
+			warn(@_);
+			syswrite($w, my $num = $! + 0);
+			_exit(1);
+		};
 		for my $child_fd (0..$#$redir) {
 			my $parent_fd = $redir->[$child_fd];
 			next if $parent_fd == $child_fd;
@@ -32,7 +38,9 @@ sub pi_fork_exec ($$$$$$$) {
 		if ($pgid >= 0 && !defined(setpgid(0, $pgid))) {
 			die "setpgid(0, $pgid): $!";
 		}
-		$SIG{$_} = 'DEFAULT' for keys %SIG;
+		for (keys %SIG) {
+			$SIG{$_} = 'DEFAULT' if substr($_, 0, 1) ne '_';
+		}
 		if ($cd ne '') {
 			chdir $cd or die "chdir $cd: $!";
 		}
@@ -49,11 +57,18 @@ sub pi_fork_exec ($$$$$$$) {
 		} else {
 			%ENV = map { split(/=/, $_, 2) } @$env;
 		}
-		exec @$cmd;
+		undef $r;
+		exec { $f } @$cmd;
 		die "exec @$cmd failed: $!";
 	}
+	close $w;
 	sigprocmask(SIG_SETMASK, $old) or die "can't unblock signals: $!";
-	$! = $syserr;
+	if (my $cerrnum = do { local $/, <$r> }) {
+		$pid = -1;
+		$! = $cerrnum;
+	} else {
+		$! = $syserr;
+	}
 	$pid;
 }
 
diff --git a/t/search.t b/t/search.t
index 56c7db1c..36a8fb30 100644
--- a/t/search.t
+++ b/t/search.t
@@ -576,6 +576,13 @@ SKIP: {
 	$q = $s->query_argv_to_string($g, [qw{OR (rt:1993-10-02)}]);
 	like($q, qr/\AOR \(rt:749\d{6}\.\.749\d{6}\)\z/,
 		'trailing parentheses preserved');
+	$ENV{TEST_EXPENSIVE} or
+		skip 'TEST_EXPENSIVE not set for argv overflow check', 1;
+	my @w;
+	local $SIG{__WARN__} = sub { push @w, @_ }; # for pure Perl version
+	my @fail = map { 'd:1993-10-02..2010-10-02' } (1..(4096 * 32));
+	eval { $s->query_argv_to_string($g, \@fail) };
+	ok($@, 'exception raised');
 }
 
 done_testing();

^ permalink raw reply related	[relevance 7%]

* [PATCH 00/13] lei approxidate, startup fix, --alert
@ 2021-02-08  9:05  6% Eric Wong
  2021-02-08  9:05  7% ` [PATCH 13/13] spawnpp: raise exception on E2BIG errors Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-02-08  9:05 UTC (permalink / raw)
  To: meta

I've redone and squashed some changes into PATCH 1/13 which
was posted yesterday.

3/13 (SIGWINCH) is rebase necessary after 1/13,
4/13 (--alert=CMD) is a generalized take on 3/13.

12/13 is...

Eric Wong (13):
  lei q: improve remote mboxrd UX + MUA
  lei_xsearch: quiet Eml warnings from remote mboxrds
  lei q: SIGWINCH process group with the terminal
  lei q: support --alert=CMD for early MUA users
  tests: favor IPv6
  ds: improve add_timer usability
  lei: start_pager: drop COLUMNS default
  lei: avoid racing on unlink + bind + listen
  lei: drop BSD::Resource usage
  git: implement date_parse method
  lei q: use git approxidate with d:, dt: and rt: ranges
  search: use one git-rev-parse process for all dates
  spawnpp: raise exception on E2BIG errors

 lib/PublicInbox/DS.pm           |  10 ++--
 lib/PublicInbox/ExtSearchIdx.pm |   5 +-
 lib/PublicInbox/FakeInotify.pm  |   4 +-
 lib/PublicInbox/Git.pm          |  10 +++-
 lib/PublicInbox/IPC.pm          |   8 +--
 lib/PublicInbox/LEI.pm          | 100 ++++++++++++++++++++++----------
 lib/PublicInbox/LeiCurl.pm      |  11 +++-
 lib/PublicInbox/LeiMirror.pm    |   5 +-
 lib/PublicInbox/LeiOverview.pm  |   6 +-
 lib/PublicInbox/LeiQuery.pm     |  12 ++--
 lib/PublicInbox/LeiToMail.pm    |  24 ++++----
 lib/PublicInbox/LeiXSearch.pm   |  97 ++++++++++++++++++++-----------
 lib/PublicInbox/Search.pm       |  86 +++++++++++++++++++++++++++
 lib/PublicInbox/SpawnPP.pm      |  23 ++++++--
 lib/PublicInbox/TestCommon.pm   |  30 ++++++++--
 lib/PublicInbox/Watch.pm        |  19 +++---
 script/lei                      |  16 ++---
 t/extsearch.t                   |   2 +-
 t/git.t                         |  17 +++++-
 t/httpd-corner.psgi             |   2 +-
 t/httpd-corner.t                |  12 ++--
 t/httpd-https.t                 |   2 +-
 t/httpd-unix.t                  |   7 +--
 t/httpd.t                       |   8 +--
 t/imapd-tls.t                   |   4 +-
 t/imapd.t                       |   8 +--
 t/lei-mirror.t                  |   2 +-
 t/nntpd-tls.t                   |   4 +-
 t/nntpd.t                       |  11 ++--
 t/psgi_attach.t                 |   2 +-
 t/psgi_v2.t                     |   2 +-
 t/search.t                      |  51 ++++++++++++++++
 t/solver_git.t                  |   2 +-
 t/v2mirror.t                    |   3 +-
 t/v2writable.t                  |   3 +-
 t/www_altid.t                   |   2 +-
 t/www_listing.t                 |   3 +-
 xt/git-http-backend.t           |   4 +-
 xt/httpd-async-stream.t         |   2 +-
 xt/imapd-mbsync-oimap.t         |   4 +-
 xt/imapd-validate.t             |   4 +-
 xt/mem-imapd-tls.t              |   2 +-
 xt/nntpd-validate.t             |   3 +-
 xt/perf-nntpd.t                 |  16 ++---
 xt/solver.t                     |   3 +-
 45 files changed, 441 insertions(+), 210 deletions(-)


^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-02-08  9:05  6% [PATCH 00/13] lei approxidate, startup fix, --alert Eric Wong
2021-02-08  9:05  7% ` [PATCH 13/13] spawnpp: raise exception on E2BIG errors 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).