unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 21380@debbugs.gnu.org
Subject: bug#21380: 25.0.50; GTK-induced segfault when scheduling timer from window-configuration-change-hook
Date: Tue, 1 Sep 2015 20:48:18 +0000	[thread overview]
Message-ID: <CAOqdjBd-LLOERx78ngF_n3fQM+O6zKbF3gbEme9t8Jwb7iT3RQ@mail.gmail.com> (raw)
In-Reply-To: <83vbbuawgy.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 846 bytes --]

On Tue, Sep 1, 2015 at 5:19 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> > The only code path that I see that's potentially dangerous is that
> atimers
> > appear to be executed even if input is blocked.
>
> Yes, that's exactly what bothered me.  Not calling QUIT prevents that.
>
> Alternatively, we could turn off atimers (by calling turn_on_atimers)
> while Fcopy_sequence runs.
>

I think that would be a better solution. I've done a quick grep for the
current atimers and at first glance they appear to be okay, but obviously
that's no guarantee for the future. It might be worth thinking about
block_input_and_atimers ().

I think it's safe to assume that Lisp timers are only checked if atimers
are enabled. If it isn't, I think the best way forward is to write
block_input_and_atimers () and lock atimers with a counter just like input
is.

[-- Attachment #1.2: Type: text/html, Size: 1301 bytes --]

[-- Attachment #2: 0001-Fix-potential-race-conditions-Bug-21380.patch --]
[-- Type: text/x-patch, Size: 1516 bytes --]

From 678bdba55e4a07e3baebad204c9fe5c55c99b3d3 Mon Sep 17 00:00:00 2001
From: Philip <pipcet@gmail.com>
Date: Tue, 1 Sep 2015 20:42:44 +0000
Subject: [PATCH] Fix potential race conditions (Bug#21380)

        * keyboard.c (timer_check): Call `block_input' and turn off
	atimers around the creation of the temporary timer list copy.

	* fns.c (concat): Don't assume argument size remains unchanged
	after call to `Fmake_list'.  Return incorrect results (but don't
	segfault) in that case.
---
 src/fns.c      | 3 +++
 src/keyboard.c | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/src/fns.c b/src/fns.c
index 26a98ab..15d9e64 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -744,6 +744,9 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
 	    /* Store this element into the result.  */
 	    if (toindex < 0)
 	      {
+                if (NILP (tail))
+                  break;
+
 		XSETCAR (tail, elt);
 		prev = tail;
 		tail = XCDR (tail);
diff --git a/src/keyboard.c b/src/keyboard.c
index dab32b1..4ce830d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -4560,6 +4560,8 @@ timer_check (void)
 
   Lisp_Object tem = Vinhibit_quit;
   Vinhibit_quit = Qt;
+  block_input ();
+  turn_on_atimers (false);
 
   /* We use copies of the timers' lists to allow a timer to add itself
      again, without locking up Emacs if the newly added timer is
@@ -4573,6 +4575,8 @@ timer_check (void)
   else
     idle_timers = Qnil;
 
+  turn_on_atimers (true);
+  unblock_input ();
   Vinhibit_quit = tem;
 
   do
-- 
2.5.0


  reply	other threads:[~2015-09-01 20:48 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-30 12:51 bug#21380: 25.0.50; GTK-induced segfault when scheduling timer from window-configuration-change-hook Pip Cet
2015-08-30 15:01 ` Eli Zaretskii
2015-08-30 15:24   ` Pip Cet
2015-08-30 15:27     ` Pip Cet
2015-08-30 16:24       ` Pip Cet
2015-08-30 18:10         ` martin rudalics
2015-08-30 18:20           ` Pip Cet
2015-08-30 19:50             ` Eli Zaretskii
2015-08-30 18:59           ` Pip Cet
2015-08-31  9:20             ` martin rudalics
2015-08-30 16:39     ` Eli Zaretskii
2015-08-30 16:42       ` Pip Cet
2015-08-30 19:44         ` Eli Zaretskii
2015-08-30 20:56           ` Pip Cet
2015-08-30 21:13             ` Pip Cet
2015-08-31 14:31             ` Eli Zaretskii
2015-09-01 10:20               ` Pip Cet
2015-09-01 15:03                 ` Eli Zaretskii
2015-09-01 15:22                   ` Pip Cet
2015-09-01 16:01                     ` Eli Zaretskii
2015-09-01 16:02                       ` Pip Cet
2015-09-01 16:23                         ` Eli Zaretskii
2015-09-02  7:02                       ` martin rudalics
2015-09-02 14:32                         ` Eli Zaretskii
2015-09-03 15:36                         ` Stefan Monnier
2015-09-05  7:38                           ` Eli Zaretskii
2015-09-05 15:18                             ` Stefan Monnier
2015-09-05 15:27                               ` Eli Zaretskii
2015-09-06 22:11                                 ` Stefan Monnier
2022-04-29 12:52                             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-29 13:40                               ` Eli Zaretskii
2022-04-29 13:44                                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-04-29 15:02                                   ` Pip Cet
2015-09-05 16:59                           ` Pip Cet
2015-09-06 22:22                             ` Stefan Monnier
2015-09-08 15:55                               ` Pip Cet
2015-09-01 15:14                 ` Pip Cet
2015-09-01 16:04                   ` Eli Zaretskii
2015-09-01 16:56                     ` Pip Cet
2015-09-01 17:19                       ` Eli Zaretskii
2015-09-01 20:48                         ` Pip Cet [this message]
2015-09-02 15:08                           ` Eli Zaretskii
2015-09-02 16:09                             ` Pip Cet
2015-09-02 19:13                               ` Eli Zaretskii
2015-09-02 22:08                                 ` Pip Cet
2020-09-07 17:07                           ` Lars Ingebrigtsen
2020-09-07 17:47                             ` Pip Cet
2020-09-07 19:09                             ` Eli Zaretskii
2020-09-08  9:57                               ` Lars Ingebrigtsen
2022-04-29 12:14                                 ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOqdjBd-LLOERx78ngF_n3fQM+O6zKbF3gbEme9t8Jwb7iT3RQ@mail.gmail.com \
    --to=pipcet@gmail.com \
    --cc=21380@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).