GNU bug report logs - #76227
SRFI 19's current-time-monotonic is not actually monotonic

Previous Next

Package: guile;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Wed, 12 Feb 2025 13:56:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 76227 <at> debbugs.gnu.org
Subject: bug#76227: SRFI 19's current-time-monotonic is not actually monotonic
Date: Wed, 12 Feb 2025 22:54:53 +0900
Hi,

Seen in srfi-19.scm:

--8<---------------cut here---------------start------------->8---
;; -- we define it to be the same as TAI.
;;    A different implementation of current-time-monotonic
;;    will require rewriting all of the time-monotonic converters,
;;    of course.

(define (current-time-monotonic)
  ;; Guile monotonic and TAI times are the same.
  (let ((tai (current-time-tai)))
    (make-time time-monotonic
               (time-nanosecond tai)
               (time-second tai))))
--8<---------------cut here---------------end--------------->8---

which as far as I can see uses CLOCK_REALTIME and not CLOCK_MONOTONIC as
it relies on gettimeofday(2), which has this note in its documentation:

    The time returned by gettimeofday() is affected by discontinuous  jumps
    in  the system time (e.g., if the system administrator manually changes
    the system time).  If you need a monotonically  increasing  clock,  see
    clock_gettime(2).

-- 
Thanks,
Maxim




This bug report was last modified 120 days ago.

Previous Next


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