On Fri, Mar 7, 2025 at 9:57 AM Jacob Champion <jacob.champ...@enterprisedb.com> wrote: > 2) macOS's EVFILT_TIMER implementation seems to be different from the > other BSDs. On Mac, when you re-add a timer to a kqueue, any existing > timer-fired events for it are not cleared out and the kqueue might > remain readable. This breaks a postcondition of our set_timer() > function, which is that new timeouts are supposed to completely > replace previous timeouts.
I don't see that behaviour on my Mac with a simple program, and that seems like it couldn't possibly be intended. Hmm... <browses source code painfully> I wonder if this atomic generation scheme has a hole in it, under concurrency... https://github.com/apple-oss-distributions/xnu/blob/8d741a5de7ff4191bf97d57b9f54c2f6d4a15585/bsd/kern/kern_event.c#L1661 The code on the other OSes just dequeues it when reprogramming the timer, which involves a lock and no doubt a few more cycles, and is clearly not quite as exciting but ...