From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#55628: debug-timer-check fails on macOS 11.6.6 Date: Wed, 25 May 2022 15:05:32 +0200 Message-ID: <015331C8-C4AF-49DB-A859-BE01012B77BF@acm.org> References: <87sfoxdcso.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_103CCC85-70B7-46C8-87B6-1A68D8DB0085" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="328"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 55628@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 25 15:06:43 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ntqip-000AVv-D0 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 May 2022 15:06:43 +0200 Original-Received: from localhost ([::1]:56574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ntqin-00064F-PX for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 May 2022 09:06:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntqiA-000603-8s for bug-gnu-emacs@gnu.org; Wed, 25 May 2022 09:06:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ntqi9-0004Nb-Vu for bug-gnu-emacs@gnu.org; Wed, 25 May 2022 09:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ntqi9-00046y-Pg for bug-gnu-emacs@gnu.org; Wed, 25 May 2022 09:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 May 2022 13:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55628 X-GNU-PR-Package: emacs Original-Received: via spool by 55628-submit@debbugs.gnu.org id=B55628.165348394415774 (code B ref 55628); Wed, 25 May 2022 13:06:01 +0000 Original-Received: (at 55628) by debbugs.gnu.org; 25 May 2022 13:05:44 +0000 Original-Received: from localhost ([127.0.0.1]:54613 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ntqhs-00046M-Gv for submit@debbugs.gnu.org; Wed, 25 May 2022 09:05:44 -0400 Original-Received: from mail239c50.megamailservers.eu ([91.136.10.249]:36014 helo=mail56c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ntqhp-000462-J7 for 55628@debbugs.gnu.org; Wed, 25 May 2022 09:05:42 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1653483934; bh=NPWMx6T/jSGTznFjWnzE3RuItRvxgKS2wRCGrxfr6mk=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=DfCHkEG0BdjXcQ81/vnHk2vU0vtqIp9TPvcdS8CCo9ABdeaNShej4uzC9VnouJLUE YHM91DE35rat/ffKMLJYgXKs5Rcgd/M12kD+ap/jF8Cu4X0tRL3nghagbLTwtLv7PV /sHn820TFTztn+ZoJEJOMZM7BpDrL8uitxtFghvM= Feedback-ID: mattiase@acm.or Original-Received: from smtpclient.apple (c188-150-171-71.bredband.tele2.se [188.150.171.71]) (authenticated bits=0) by mail56c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 24PD5WAB015484; Wed, 25 May 2022 13:05:34 +0000 In-Reply-To: <87sfoxdcso.fsf@gnus.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) X-CTCH-RefID: str=0001.0A742F28.628E299E.00A5, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:233056 Archived-At: --Apple-Mail=_103CCC85-70B7-46C8-87B6-1A68D8DB0085 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 25 maj 2022 kl. 14.20 skrev Lars Ingebrigtsen : >=20 > Mattias Engdeg=C3=A5rd writes: >=20 >> Built with enable-checking, (debug-timer-check) returns nil. >> It turns out that debug_timer_callback is never actually called, but = I >> haven't dug further than that. >>=20 >> This is on macOS 11.6.6 and HAVE_TIMERFD is not defined. Does this >> code path work on other systems? >=20 > I tried this on Debian/bookworm (with nativecomp, but that probably > doesn't make a difference), and I got nil there, too. Thanks for checking. Apparently pending_signals is never set; = handle_alarm_signal is never called. More digging shows that set_alarm always sets the interval timer to at = least 1 ms in the future even if the timer has expired. The attached patch makes set_alarm signal SIGALRM immediately if the = timer is due. We could call the signal handler directly but this way it = should work correctly if the signal is masked at the moment. What do you = think? --Apple-Mail=_103CCC85-70B7-46C8-87B6-1A68D8DB0085 Content-Disposition: attachment; filename=set_alarm.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="set_alarm.diff" Content-Transfer-Encoding: 7bit diff --git a/src/atimer.c b/src/atimer.c index 1c6c881fc0..c26904e1f0 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -297,11 +297,6 @@ set_alarm (void) { if (atimers) { -#ifdef HAVE_SETITIMER - struct itimerval it; -#endif - struct timespec now, interval; - #ifdef HAVE_ITIMERSPEC if (0 <= timerfd || alarm_timer_ok) { @@ -337,20 +332,24 @@ set_alarm (void) } #endif - /* Determine interval till the next timer is ripe. - Don't set the interval to 0; this disables the timer. */ - now = current_timespec (); - interval = (timespec_cmp (atimers->expiration, now) <= 0 - ? make_timespec (0, 1000 * 1000) - : timespec_sub (atimers->expiration, now)); + /* Determine interval till the next timer is ripe. */ + struct timespec now = current_timespec (); + if (timespec_cmp (atimers->expiration, now) <= 0) + { + /* Timer is (over)due -- just trigger the signal right way. */ + raise (SIGALRM); + } + else + { + struct timespec interval = timespec_sub (atimers->expiration, now); #ifdef HAVE_SETITIMER - - memset (&it, 0, sizeof it); - it.it_value = make_timeval (interval); - setitimer (ITIMER_REAL, &it, 0); -#endif /* not HAVE_SETITIMER */ - alarm (max (interval.tv_sec, 1)); + struct itimerval it = {.it_value = make_timeval (interval)}; + setitimer (ITIMER_REAL, &it, 0); +#else + alarm (max (interval.tv_sec, 1)); +#endif + } } } --Apple-Mail=_103CCC85-70B7-46C8-87B6-1A68D8DB0085--