From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: daimrod@omecha.info (=?UTF-8?Q?Gr=C3=A9goire?= Jadi) Newsgroups: gmane.emacs.bugs Subject: bug#29170: Infinite loop noticed on Emacs in OpenBSD Date: Fri, 17 Nov 2017 15:36:19 +0100 Message-ID: <87bmk17z18.fsf@omecha.info> References: <87fu9rwksm.fsf@omecha.info> <87fu9n7aq9.fsf@elite.giraud> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1510929500 23415 195.159.176.226 (17 Nov 2017 14:38:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Nov 2017 14:38:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (berkeley-unix) Cc: 29170@debbugs.gnu.org To: Manuel Giraud Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 17 15:38:17 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFhmZ-0005e1-GO for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Nov 2017 15:38:15 +0100 Original-Received: from localhost ([::1]:46247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFhmf-0007Fg-Ch for geb-bug-gnu-emacs@m.gmane.org; Fri, 17 Nov 2017 09:38:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFhlQ-0006KV-QC for bug-gnu-emacs@gnu.org; Fri, 17 Nov 2017 09:37:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFhlO-0006nN-4u for bug-gnu-emacs@gnu.org; Fri, 17 Nov 2017 09:37:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35737) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eFhlO-0006md-1j for bug-gnu-emacs@gnu.org; Fri, 17 Nov 2017 09:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eFhlN-0000R6-Ij for bug-gnu-emacs@gnu.org; Fri, 17 Nov 2017 09:37:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87fu9rwksm.fsf@omecha.info> Resent-From: daimrod@omecha.info (=?UTF-8?Q?Gr=C3=A9goire?= Jadi) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Nov 2017 14:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29170 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29170-submit@debbugs.gnu.org id=B29170.15109293891638 (code B ref 29170); Fri, 17 Nov 2017 14:37:01 +0000 Original-Received: (at 29170) by debbugs.gnu.org; 17 Nov 2017 14:36:29 +0000 Original-Received: from localhost ([127.0.0.1]:44418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFhkr-0000QM-JR for submit@debbugs.gnu.org; Fri, 17 Nov 2017 09:36:29 -0500 Original-Received: from a.omecha.info ([89.234.176.136]:38134 helo=omecha.info) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFhkp-0000Q3-KU for 29170@debbugs.gnu.org; Fri, 17 Nov 2017 09:36:28 -0500 Original-Received: from puffy.omecha.info (unknown [192.168.99.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by omecha.info (Postfix) with ESMTPSA id 4ED24590; Fri, 17 Nov 2017 15:36:20 +0100 (CET) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:140005 Archived-At: Manuel Giraud writes: > Hi, Hello Manuel, Thanks for the reply and sorry for the delay. > Here is a patch against HEAD to avoid the hang in infinite loop. The > 'x-selection-timeout' pause will still be there even with this patch. I've tested your patch on emacs-25-3.1 and it does prevent the infinite loop. However, if the user sends input to emacs while it is waiting, it raises the following backtrace : Debugger entered--Lisp error: (error "Timed out waiting for reply from selection owner") x-get-selection-internal(SECONDARY STRING nil nil) #[1026 "\300$\207" [x-get-selection-internal] 9 "\n\n(fn SELECTION-SYMBOL TARGET-TYPE &optional TIME-STAMP TERMINAL)"](SECONDARY STRING) apply(#[1026 "\300$\207" [x-get-selection-internal] 9 "\n\n(fn SELECTION-SYMBOL TARGET-TYPE &optional TIME-STAMP TERMINAL)"] (SECONDARY STRING)) gui-backend-get-selection(SECONDARY STRING) gui-get-selection(SECONDARY STRING) (let ((value (quote SECONDARY)) (x-selection-timeout 2000)) (gui-get-selection value (quote UTF8_STRING)) (gui-get-selection value (quote COMPOUND_TEXT)) (gui-get-selection value (quote STRING)) (gui-get-selection value (quote TEXT))) eval((let ((value (quote SECONDARY)) (x-selection-timeout 2000)) (gui-get-selection value (quote UTF8_STRING)) (gui-get-selection value (quote COMPOUND_TEXT)) (gui-get-selection value (quote STRING)) (gui-get-selection value (quote TEXT))) nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp) But it's still better than a complete freeze IMO. > My understandings: > > On OpenBSD, most of the time, the function > "xselect.c/x_get_foreign_selection" won't get a SelectNotify with > (SECONDARY, TEXT) as arguments (that I did not understand and it might > never happen on other oses). > > But then, while waiting at most 'x-selection-timeout' into > "process.c/wait_reading_process_output" the 'now' variable won't have a > chance of being invalidated or updated and that is what cause the > infinite loop. > > Someone more knowledgeable of "process.c/wait_reading_process_output" > might have a better solution to this problem. > > diff --git a/src/process.c b/src/process.c > index fc46e74332..25bd28a82b 100644 > --- a/src/process.c > +++ b/src/process.c > @@ -5115,8 +5115,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, > /* Exit if already run out. */ > if (wait == TIMEOUT) > { > - if (!timespec_valid_p (now)) > - now = current_timespec (); > + now = current_timespec (); > if (timespec_cmp (end_time, now) <= 0) > break; > timeout = timespec_sub (end_time, now);