Subject: bug#55628: debug-timer-check fails on macOS 11.6.6

From: Mattias Engdegård <[email-masked]>
Date: Thu, 26 May 2022 11:57:58 +0200

25 maj 2022 kl. 19.11 skrev Eli Zaretskii <[email-masked]>:

> Btw, this test will never work on a platform that only has setitimer,
> because only one ITIMER_REAL timer is guaranteed to exist, and the
> function attempts to arm 10 timers at the same time.

That's not how the code works. `setitimer` will only be called for the first timer to expire.
(The test works correctly on this computer, that only has setitimer, after applying the patch.)

Another demonstration of this bug:

(funcall-with-delayed-message
 0.1 "haha" (lambda () (sit-for 3)))

will, on this machine, display "haha" after 1 s if unpatched, but after 0.1 s if patched.

(This is with -nw because the NS backend seems to be slow handling async events on its own, but that's a different bug.)

> We don't usually have testing code in a production build, so why make
> an exception here?  Especially since atimers are an obscure feature
> used internally by Emacs.

There's nothing bad or even unusual about including interfaces for internal testing in production builds, as long as it doesn't unduly reduce performance or cause significant bloat. It's always a trade-off, of course.