GNU bug report logs - #21380
25.0.50; GTK-induced segfault when scheduling timer from window-configuration-change-hook

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> gmail.com>

Date: Sun, 30 Aug 2015 12:52:02 UTC

Severity: normal

Found in version 25.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #107 received at 21380 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: rudalics <at> gmx.at, pipcet <at> gmail.com, 21380 <at> debbugs.gnu.org
Subject: Re: bug#21380: 25.0.50;
 GTK-induced segfault when scheduling timer from
 window-configuration-change-hook
Date: Sat, 05 Sep 2015 10:38:53 +0300
> From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Pip Cet <pipcet <at> gmail.com>,
>         21380 <at> debbugs.gnu.org
> Date: Thu, 03 Sep 2015 11:36:44 -0400
> 
> >> So maybe we should introduce a special copy_sequence_no_quit function
> >> that never calls QUIT, and then use it for copying the timer lists.
> 
> That'd be OK, yes.

I believe the currently preferred solution is to block input and
atimers while copying the timer lists to local copies.  Are you okay
with that?

> This said, maybe an even better solution would be to avoid the copy
> altogether.
> 
> AFAICT these lists are only ever side-effected by timer.el's
> timer--activate, which has a special `reuse-cell' argument just to be
> able to do that.
> 
> I'm not completely sure why we do it this way, but my naive
> understanding is the following:
> - For historical reasons of limited resources, timer.el tries hard to
>   avoid allocating cons cells.
> - Then many years later we found a problem with this cell-reuse and
>   circumvented it by copying the whole list all the time.
> - So we end up working hard to avoid allocating a couple cells on one
>   side, only to end up allocating many more on the other.
> 
> Maybe we should go back to bugs #12447 and #12326 and see if just
> removing the "reuse-cell" code (and the Fcopy_sequence(s)) fixes the
> problem as well.

I'm not sure I understand this plan.  Are you saying that consing a
new list in timer--activate, instead of reusing an existing cell, will
avoid the need to wok on a copy of the timer's list when invoking the
timer callbacks?  If so, I'm probably missing something here, because
timer--activate will update the timer list variable anyway, and we
have the same problem, whereby the list changes under our feet, back
again.

IOW, if some Lisp run by a timer callback ends up doing (directly or
indirectly) something like

  (setq timer-list (cons my-new-timer timer-list))

doesn't it mean the value of Vtimer_list in C seen by timer_check
changes as well that very moment?

Not to mention the fact that with timers firing every several tens of
ms, something we've seen while discussing these bugs, allocating a
couple of cells each time might cause a lot of consing per second,
which in turn causes GC, which slows down everything.




This bug report was last modified 3 years and 75 days ago.

Previous Next


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