File 1051-erts-Fix-monotonicity-of-Erlang-monotonic-time.patch of Package erlang

From fee8f704f22494842c0db98352c8239882ecfaec Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Wed, 26 Jun 2024 11:23:03 +0200
Subject: [PATCH] [erts] Fix monotonicity of Erlang monotonic time

When 'no time warp mode' was enabled, a smaller Erlang monotonic time
could be read than a previously read time, i.e., breaking the monotonic
property. The runtime system will abort when detecting an issue like
this since OTP 24.3.4.17 and OTP 25.0.

On systems with a fine grained time unit, the window for this happening
was very small, but still existed. On systems with native nanosecond
time unit, which are most if not all non-Windows systems, two readings
needed to be done within 20 nanoseconds.
---
 erts/emulator/beam/erl_time_sup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/erts/emulator/beam/erl_time_sup.c b/erts/emulator/beam/erl_time_sup.c
index 0e1d4b087f..5d3400d327 100644
--- a/erts/emulator/beam/erl_time_sup.c
+++ b/erts/emulator/beam/erl_time_sup.c
@@ -276,7 +276,8 @@ calc_corrected_erl_mtime(ErtsMonotonicTime os_mtime,
 	diff += (cip->correction.drift*diff)/ERTS_MONOTONIC_TIME_UNIT;
     erl_mtime = cip->erl_mtime;
     erl_mtime += diff;
-    erl_mtime += cip->correction.error*(diff/ERTS_TCORR_ERR_UNIT);
+    erl_mtime += (cip->correction.error*diff)/ERTS_TCORR_ERR_UNIT;
+
     if (os_mdiff_p)
 	*os_mdiff_p = diff;
     return erl_mtime;
-- 
2.35.3

openSUSE Build Service is sponsored by