GNU bug report logs - #1082
23.0.60; read-char unexpectedly halts execution of script

Previous Next

Package: emacs;

Reported by: Markus Triska <markus.triska <at> gmx.at>

Date: Sat, 4 Oct 2008 18:05:04 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1082 in the body.
You can then email your comments to 1082 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1082; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; read-char unexpectedly halts execution of script
Date: Sat,  4 Oct 2008 19:58:16 +0200 (CEST)
Let filter.el consist of the forms:

   (defun bc-filter (proc string)
     (message "%s" string))

   (message "starting")
   (setq bc (start-process "bc" nil "/usr/bin/bc"))
   (set-process-filter bc 'bc-filter)

   (while t
     (let ((char (read-char nil nil 0.1)))
       (message "char: %s" char)))

Where "/usr/bin/bc" is the GNU arbitrary precision calculator. Now:

   mt-computer:~ mt$ emacs --script filter.el
   starting
   mt-computer:~ mt$

I expect non-termination in this case, as in eval-buffer on filter.el.

In GNU Emacs 23.0.60.1 (i386-apple-darwin8.11.1, GTK+ Version 2.12.9)
 of 2008-09-24 on mt-computer.local
Windowing system distributor `The XFree86 Project, Inc', version 11.0.40400000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1082; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Chong Yidong <cyd <at> stupidchicken.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 1082 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: emacs-devel <at> gnu.org
Cc: 1082 <at> debbugs.gnu.org
Subject: Re: 23.0.60; read-char unexpectedly halts execution of script
Date: Mon, 06 Oct 2008 15:08:44 -0400
> Let filter.el consist of the forms:
>
>    (defun bc-filter (proc string)
>      (message "%s" string))
>
>    (message "starting")
>    (setq bc (start-process "bc" nil "/usr/bin/bc"))
>    (set-process-filter bc 'bc-filter)
>
>    (while t
>      (let ((char (read-char nil nil 0.1)))
>        (message "char: %s" char)))
>
> Where "/usr/bin/bc" is the GNU arbitrary precision calculator. Now:
>
>    mt-computer:~ mt$ emacs --script filter.el
>    starting
>    mt-computer:~ mt$
>
> I expect non-termination in this case, as in eval-buffer on filter.el.

This broke when SYNC_INPUT became the default; it works when Emacs is
recompiled without SYNC_INPUT, like Emacs 22.

I don't know what the specific cause of failure is, however.  Maybe the
SYNC_INPUT code should only be active when Emacs is run interactively.

Thoughts?




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1082; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Chong Yidong <cyd <at> stupidchicken.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #15 received at 1082 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: emacs-devel <at> gnu.org
Cc: 1082 <at> debbugs.gnu.org
Subject: Re: 23.0.60; read-char unexpectedly halts execution of script
Date: Mon, 06 Oct 2008 15:35:28 -0400
Chong Yidong <cyd <at> stupidchicken.com> writes:

>> Let filter.el consist of the forms:
>>
>>    (defun bc-filter (proc string)
>>      (message "%s" string))
>>
>>    (message "starting")
>>    (setq bc (start-process "bc" nil "/usr/bin/bc"))
>>    (set-process-filter bc 'bc-filter)
>>
>>    (while t
>>      (let ((char (read-char nil nil 0.1)))
>>        (message "char: %s" char)))
>>
>> Where "/usr/bin/bc" is the GNU arbitrary precision calculator. Now:
>>
>>    mt-computer:~ mt$ emacs --script filter.el
>>    starting
>>    mt-computer:~ mt$
>>
>> I expect non-termination in this case
>
> This broke when SYNC_INPUT became the default.

To pin it down further, this breakage seems to be due to not using
SA_RESTART in the signal handler.  If we set SA_RESTARTi in sysdep.c,
the problem disappears.  Stefan, could you comment?

signal_handler_t
sys_signal (int signal_number, signal_handler_t action)
{
  struct sigaction new_action, old_action;
  sigemptyset (&new_action.sa_mask);
  new_action.sa_handler = action;
#if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) && !defined(SYNC_INPUT)
  /* Emacs mostly works better with restartable system services. If this
     flag exists, we probably want to turn it on here.
     However, on some systems this resets the timeout of `select'
     which means that `select' never finishes if it keeps getting signals.
     BROKEN_SA_RESTART is defined on those systems.  */
  /* It's not clear why the comment above says "mostly works better".  --Stef
     When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll
     for pending input so we need long-running syscalls to be interrupted
     after a signal that sets the interrupt_input_pending flag.  */
  new_action.sa_flags = SA_RESTART;
#else
  new_action.sa_flags = 0;
#endif
  sigaction (signal_number, &new_action, &old_action);
  return (old_action.sa_handler);
}




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1082; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #20 received at 1082 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: "Lennart Borgman (gmail)" <lennart.borgman <at> gmail.com>
To: Chong Yidong <cyd <at> stupidchicken.com>, 1082 <at> debbugs.gnu.org
Cc: emacs-devel <at> gnu.org
Subject: Re: bug#1082: 23.0.60; read-char unexpectedly halts execution of
 script
Date: Mon, 06 Oct 2008 21:34:45 +0200
Chong Yidong wrote:
>> Let filter.el consist of the forms:
>>
>>    (defun bc-filter (proc string)
>>      (message "%s" string))
>>
>>    (message "starting")
>>    (setq bc (start-process "bc" nil "/usr/bin/bc"))
>>    (set-process-filter bc 'bc-filter)
>>
>>    (while t
>>      (let ((char (read-char nil nil 0.1)))
>>        (message "char: %s" char)))
>>
>> Where "/usr/bin/bc" is the GNU arbitrary precision calculator. Now:
>>
>>    mt-computer:~ mt$ emacs --script filter.el
>>    starting
>>    mt-computer:~ mt$
>>
>> I expect non-termination in this case, as in eval-buffer on filter.el.
> 
> This broke when SYNC_INPUT became the default; it works when Emacs is
> recompiled without SYNC_INPUT, like Emacs 22.
> 
> I don't know what the specific cause of failure is, however.  Maybe the
> SYNC_INPUT code should only be active when Emacs is run interactively.
> 
> Thoughts?


What is the while loop supposed to do? I tested just that and I got a
bit weird results.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1082; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Andreas Schwab <schwab <at> suse.de>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #25 received at 1082 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: Chong Yidong <cyd <at> stupidchicken.com>
Cc: emacs-devel <at> gnu.org, 1082 <at> debbugs.gnu.org
Subject: Re: 23.0.60; read-char unexpectedly halts execution of script
Date: Mon, 06 Oct 2008 23:28:06 +0200
Chong Yidong <cyd <at> stupidchicken.com> writes:

>> Let filter.el consist of the forms:
>>
>>    (defun bc-filter (proc string)
>>      (message "%s" string))
>>
>>    (message "starting")
>>    (setq bc (start-process "bc" nil "/usr/bin/bc"))
>>    (set-process-filter bc 'bc-filter)
>>
>>    (while t
>>      (let ((char (read-char nil nil 0.1)))
>>        (message "char: %s" char)))
>>
>> Where "/usr/bin/bc" is the GNU arbitrary precision calculator. Now:
>>
>>    mt-computer:~ mt$ emacs --script filter.el
>>    starting
>>    mt-computer:~ mt$
>>
>> I expect non-termination in this case, as in eval-buffer on filter.el.
>
> This broke when SYNC_INPUT became the default; it works when Emacs is
> recompiled without SYNC_INPUT, like Emacs 22.
>
> I don't know what the specific cause of failure is, however.  Maybe the
> SYNC_INPUT code should only be active when Emacs is run interactively.
>
> Thoughts?

In non-interactive mode we always want restartable syscalls, since
keyboard input goes through stdio (SYNC_INPUT makes no difference here).
I've checked in a fix.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab <at> suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




bug closed, send any further explanations to Markus Triska <markus.triska <at> gmx.at> Request was from Chong Yidong <cyd <at> stupidchicken.com> to control <at> emacsbugs.donarmstrong.com. (Mon, 06 Oct 2008 21:55:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1082; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #32 received at 1082 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: Andreas Schwab <schwab <at> suse.de>
Cc: 1082 <at> debbugs.gnu.org
Subject: Re: bug#1082: 23.0.60; read-char unexpectedly halts execution of script
Date: Tue, 07 Oct 2008 00:17:02 +0200
Andreas Schwab <schwab <at> suse.de> writes:

> In non-interactive mode we always want restartable syscalls, since
> keyboard input goes through stdio (SYNC_INPUT makes no difference here).
> I've checked in a fix.

Thank you, it fixes this problem for me. Could process output also be
handled, as in interactive use? E.g., M-x eval-region on the forms:

   (defun bc-filter (proc string)
     (message "%s" string))

   (message "starting")
   (setq bc (start-process "bc" nil "/usr/bin/bc"))
   (set-process-filter bc 'bc-filter)

   (while t
     (let ((char (read-char nil nil 0.1)))
       (when char
         (message "char: %s" char))))

processes the output of bc, and shows:

   starting
   bc 1.06
   Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
   This is free software with ABSOLUTELY NO WARRANTY.
   For details type `warranty'.

Whereas in "emacs --script" mode, this output is not shown.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1082; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #37 received at 1082 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Andreas Schwab <schwab <at> suse.de>
Cc: Chong Yidong <cyd <at> stupidchicken.com>, 1082 <at> debbugs.gnu.org,
        emacs-devel <at> gnu.org
Subject: Re: 23.0.60; read-char unexpectedly halts execution of script
Date: Mon, 06 Oct 2008 22:09:58 -0400
> In non-interactive mode we always want restartable syscalls, since
> keyboard input goes through stdio (SYNC_INPUT makes no difference here).
> I've checked in a fix.

Thank you.  Could you add a comment explaining why we test
`noninteractive' at that spot, please?


        Stefan




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Tue, 04 Nov 2008 15:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 16 years and 294 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.