NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/56422: zgrep -l sometimes hangs
The following reply was made to PR bin/56422; it has been noted by GNATS.
From: "J. Hannken-Illjes" <hannken%eis.cs.tu-bs.de@localhost>
To: NetBSD GNATS <gnats-bugs%netbsd.org@localhost>
Cc:
Subject: Re: bin/56422: zgrep -l sometimes hangs
Date: Fri, 1 Oct 2021 10:24:35 +0200
--Apple-Mail=_F96C3087-5ABC-4251-A0DF-3EE8023164D3
Content-Type: multipart/mixed;
boundary="Apple-Mail=_8A66DE72-488D-452C-8D71-E5933D0728BA"
--Apple-Mail=_8A66DE72-488D-452C-8D71-E5933D0728BA
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
This deadlock happens whenever the writer has more data and no space
while the reader is closing the pipe.
Simply swapping the EOF test and the wait_sig in pipe_write() should
fix it. Diff attached, please give it a try.
--
J. Hannken-Illjes - hannken%eis.cs.tu-bs.de@localhost - TU Braunschweig (Germany)
--Apple-Mail=_8A66DE72-488D-452C-8D71-E5933D0728BA
Content-Disposition: attachment;
filename=002_pipe_stall.diff
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="002_pipe_stall.diff"
Content-Transfer-Encoding: 7bit
pipe_stall
Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".
Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".
PR bin/56422 "zgrep -l sometimes hangs"
diff -r c0d659b6a82c -r 4b3d02a50e12 sys/kern/sys_pipe.c
--- sys/kern/sys_pipe.c
+++ sys/kern/sys_pipe.c
@@ -694,11 +694,6 @@ pipe_write(file_t *fp, off_t *offset, st
break;
}
- pipeunlock(wpipe);
- error = cv_wait_sig(&wpipe->pipe_wcv, lock);
- (void)pipelock(wpipe, false);
- if (error != 0)
- break;
/*
* If read side wants to go away, we just issue a signal
* to ourselves.
@@ -707,6 +702,12 @@ pipe_write(file_t *fp, off_t *offset, st
error = EPIPE;
break;
}
+
+ pipeunlock(wpipe);
+ error = cv_wait_sig(&wpipe->pipe_wcv, lock);
+ (void)pipelock(wpipe, false);
+ if (error != 0)
+ break;
wakeup_state = wpipe->pipe_state;
}
}
--Apple-Mail=_8A66DE72-488D-452C-8D71-E5933D0728BA--
--Apple-Mail=_F96C3087-5ABC-4251-A0DF-3EE8023164D3
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEE2BL3ha7Xao4WUZVYKoaVJdNr+uEFAmFWxcMACgkQKoaVJdNr
+uFP8wf+OGOuRE1cfL/BBDkC6cLJkLoEG38KTRB+CpFgpeck+PSpMzpAStiYSzb0
mSa4Ukomg/WOk6zbgGygtX8ZIMG54kJJJUh4dmMD51KunyzGu5RjYCOMvxni2Rup
U0T2i1hIoE+3EW2WTpizXEBTShYmJdGUFO9FLR4qvWRYNY7ml42Cuz5ofQRabN0v
6lUp/ony86XfnKuBMaezFPAUR67g2dSyf30Mdr8WgrPuOiwxha2DkBUdC/9eTkIR
zttzoAkiC970x12VHAV4VDWi/gPhZhvMa+ZOqs3U/OhwvXd5BHv8d9bEu/8KKNCI
zIBA8/rNS+3jcx5NKStznCYtGdQs2A==
=ODAS
-----END PGP SIGNATURE-----
--Apple-Mail=_F96C3087-5ABC-4251-A0DF-3EE8023164D3--
Home |
Main Index |
Thread Index |
Old Index