[no subject]

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


+  /* Make sure the RTC supports interrupts */
+  if (!switch_interrupts(0)) {
+    close(fd);
+    return 0;
+  }

But what I see happening is this:

gdb) b RTC_Finalise
Breakpoint 1 at 0x11bc8: file rtc.c, line 162.
(gdb) b RTC_Initialise
Breakpoint 2 at 0x119b8: file rtc.c, line 115.
(gdb) b RTC_Linux_Initialise
Breakpoint 3 at 0x373e8: file rtc_linux.c, line 509.
(gdb) b switch_interrupts
Breakpoint 4 at 0x36d28: switch_interrupts. (2 locations)
(gdb) run -d -s -f /root/chronyd.conf
Starting program: /home/ubuntu/chrony/chronyd -d -s -f /root/chronyd.conf
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/powerpc64le-linux-gnu/libthread_db.so.1".
2019-12-11T14:43:05Z chronyd version DEVELOPMENT starting (+CMDMON +NTP
+REFCLOCK +RTC +PRIVDROP -SCFILTER -SIGND +ASYNCDNS +SECHASH +IPV6 -DEBUG)
2019-12-11T14:43:05Z Wrong owner of /var/run/chrony (UID != 0)
2019-12-11T14:43:05Z Disabled command socket /var/run/chrony/chronyd.sock

Breakpoint 2, 0x00000001000119b8 in RTC_Initialise (initial_set=1) at
rtc.c:115
115     {
(gdb) n
125       if (initial_set) {
(gdb)
126         driftfile_time = get_driftfile_time();
(gdb)
128         if (driver.time_pre_init &&
driver.time_pre_init(driftfile_time)) {
(gdb)
129           driver_preinit_ok = 1;
(gdb)
137       driver_initialised = 0;
(gdb)
141       file_name = CNF_GetRtcFile();
(gdb)
143       if (file_name) {
(gdb)
144         if (CNF_GetRtcSync()) {
(gdb)
149           if ((driver.init)()) {
(gdb)
Breakpoint 3, 0x00000001000373e8 in RTC_Linux_Initialise () at
rtc_linux.c:509
509     {
(gdb)
511       fd = open(CNF_GetRtcDevice(), O_RDWR);
(gdb)
512       if (fd < 0) {
(gdb)
519       if (!switch_interrupts(0)) {
(gdb)
Breakpoint 4, 0x0000000100036d28 in switch_interrupts (on_off=0) at
rtc_linux.c:489
489     {
(gdb)
490       if (ioctl(fd, on_off ? RTC_UIE_ON : RTC_UIE_OFF, 0) < 0) {
(gdb)
RTC_Linux_Initialise () at rtc_linux.c:525
525       UTI_FdSetCloexec(fd);
(gdb)
527       rtc_sec = MallocArray(time_t, MAX_SAMPLES);
(gdb)
528       rtc_trim = MallocArray(double, MAX_SAMPLES);
(gdb)
529       system_times = MallocArray(struct timespec, MAX_SAMPLES);
(gdb)
532       setup_config();
(gdb)
535       coefs_file_name = CNF_GetRtcFile();
(gdb)
537       n_samples = 0;
(gdb)
538       n_samples_since_regression = 0;
(gdb)
539       n_runs = 0;
(gdb)
540       coefs_valid = 0;
(gdb)
547       SCH_AddFileHandler(fd, SCH_FILE_INPUT, read_from_device, NULL);
(gdb)
550       LCL_AddParameterChangeHandler(slew_samples, NULL);
(gdb)
552       logfileid = CNF_GetLogRtc() ? LOG_FileOpen("rtc",
(gdb)
555       return 1;
(gdb)
RTC_Initialise (initial_set=<optimized out>) at rtc.c:150
150             driver_initialised = 1;
(gdb)
main (argc=<optimized out>, argv=0x7ffffffff558) at main.c:555
555       SRC_Initialise();
(gdb)
556       RCL_Initialise();
(gdb)
557       KEY_Initialise();
(gdb)
558       SCK_Initialise();
(gdb)
561       CAM_Initialise(address_family);
(gdb)
562       NIO_Initialise(address_family);
(gdb)
563       NCR_Initialise();
(gdb)
564       CNF_SetupAccessRestrictions();
(gdb)
567       if (!sched_priority) {
(gdb)
568         sched_priority = CNF_GetSchedPriority();
(gdb)
570       if (sched_priority) {
(gdb)
574       if (lock_memory || CNF_GetLockMemory()) {
(gdb)
579       if (!geteuid() && (pw->pw_uid || pw->pw_gid))
(gdb)
582       REF_Initialise();
(gdb)
2019-12-11T14:43:52Z Initial frequency -21.507 ppm
583       SST_Initialise();
(gdb)
584       NSR_Initialise();
(gdb)
585       NSD_Initialise();
(gdb)
586       CLG_Initialise();
(gdb)
587       MNL_Initialise();
(gdb)
588       TMC_Initialise();
(gdb)
589       SMT_Initialise();
(gdb)
592       initialised = 1;
(gdb)
594       UTI_SetQuitSignalsHandler(signal_cleanup, 1);
(gdb)
596       CAM_OpenUnixSocket();
(gdb)
598       if (scfilter_level)
(gdb)
601       if (ref_mode == REF_ModeNormal && CNF_GetInitSources() > 0) {
(gdb)
605       REF_SetModeEndHandler(reference_mode_end);
(gdb)
606       REF_SetMode(ref_mode);
(gdb)
608       if (timeout > 0)
(gdb)
611       if (do_init_rtc) {
(gdb)
612         RTC_TimeInit(post_init_rtc_hook, NULL);
(gdb)
Breakpoint 4, 0x0000000100036d28 in switch_interrupts (on_off=1) at
rtc_linux.c:489
489     {
(gdb)
490       if (ioctl(fd, on_off ? RTC_UIE_ON : RTC_UIE_OFF, 0) < 0) {
(gdb)
488     switch_interrupts(int on_off)
(gdb)
2019-12-11T14:44:14Z Could not enable RTC interrupt : Invalid argument
main (argc=<optimized out>, argv=0x7ffffffff558) at main.c:619
619       SCH_MainLoop();
(gdb)
<hang>



The latter part in more detail:

612         RTC_TimeInit(post_init_rtc_hook, NULL);
(gdb) s
RTC_TimeInit (after_hook=0x10000cb60 <post_init_rtc_hook>, anything=0x0) at
rtc.c:182
182       if (driver_initialised && driver_preinit_ok) {
(gdb) n
183         (driver.time_init)(after_hook, anything);
(gdb) s
RTC_Linux_TimeInit (after_hook=0x10000cb60 <post_init_rtc_hook>,
anything=0x0) at rtc_linux.c:885
885       after_init_hook = after_hook;
(gdb) n
886       after_init_hook_arg = anything;
(gdb) n
888       operating_mode = OM_INITIAL;
(gdb) n
889       timeout_id = 0;
(gdb) n
890       switch_interrupts(1);
(gdb) n
Breakpoint 4, 0x0000000100036d28 in switch_interrupts (on_off=1) at
rtc_linux.c:489
489     {
(gdb) bt
#0  0x0000000100036d28 in switch_interrupts (on_off=1) at rtc_linux.c:489
#1  0x0000000100011c74 in RTC_TimeInit (after_hook=<optimized out>,
anything=<optimized out>) at rtc.c:183
#2  0x0000000100004878 in main (argc=<optimized out>, argv=0x7ffffffff558)
at main.c:612


That means the first switch_interrupts call from RTC_Initialise ->
RTC_Linux_Initialise -> switch_interrupts has on_off=0 and that doesn't
trigger the issue at initialization phase.
Later on on RTC_TimeInit -> switch_interrupts argument on_off=1 and the
issue occurs.
Turns out our "problematic" RTCs only trigger the issue on on_off=1.
Can we safely set that to 1 in the check like?

diff --git a/rtc_linux.c b/rtc_linux.c
index aee768f..b1eee19 100644
--- a/rtc_linux.c
+++ b/rtc_linux.c
@@ -516,7 +516,7 @@ RTC_Linux_Initialise(void)
   }



   /* Make sure the RTC supports interrupts */


-  if (!switch_interrupts(0)) {


+  if (!switch_interrupts(1)) {


     close(fd);


     return 0;


   }

Or do we need some code to then revert that setting immediately to be on
the safe side?

diff --git a/rtc_linux.c b/rtc_linux.c
index aee768f..8d0fae5 100644
--- a/rtc_linux.c
+++ b/rtc_linux.c
@@ -516,7 +516,7 @@ RTC_Linux_Initialise(void)
   }

   /* Make sure the RTC supports interrupts */
-  if (!switch_interrupts(0)) {
+  if (!switch_interrupts(1) || switch_interrupts(0)) {
     close(fd);
     return 0;
   }

Maybe even something with a harder implication on the order those are
executed.
I tested the second of the above and it did now trigger the issue when
called from RTC_Linux_Initialise.
It also did not set driver_initialised=1 this time.


Now it behaves more like expected:
Breakpoint 3, 0x00000001000373e8 in RTC_Linux_Initialise () at
rtc_linux.c:509
509     {
(gdb) n
511       fd = open(CNF_GetRtcDevice(), O_RDWR);
(gdb)
512       if (fd < 0) {
(gdb)
519       if (!switch_interrupts(1) || switch_interrupts(0)) {
(gdb)

Breakpoint 2, 0x0000000100036d28 in switch_interrupts (on_off=1) at
rtc_linux.c:489
489     {
(gdb) n
490       if (ioctl(fd, on_off ? RTC_UIE_ON : RTC_UIE_OFF, 0) < 0) {
(gdb) n
488     switch_interrupts(int on_off)
(gdb)
2019-12-11T14:58:46Z Could not enable RTC interrupt : Invalid argument
RTC_Linux_Initialise () at rtc_linux.c:520
520         close(fd);
(gdb) n
521         return 0;


Nevertheless it hangs eventually in this mode.
This is due to SCH_MainLoop begin the one with the select call where
nothing returns.

Program received signal SIGINT, Interrupt.
0x00007ffff7c40864 in __GI___select (nfds=514, readfds=0x7fffffffede8,
writefds=0x0, exceptfds=0x0, timeout=0x0) at
.../sysdeps/unix/sysv/linux/select.c:41
41      ../sysdeps/unix/sysv/linux/select.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7c40864 in __GI___select (nfds=514, readfds=0x7fffffffede8,
writefds=0x0, exceptfds=0x0, timeout=0x0) at
.../sysdeps/unix/sysv/linux/select.c:41
#1  0x0000000100014440 in SCH_MainLoop () at sched.c:753
#2  0x0000000100004880 in main (argc=<optimized out>, argv=0x7ffffffff558)
at main.c:619

I've understood that you wanted it to hard-fail and bail out of -s was set
but RTC init failed right?
Therefore I'd have expected an exit in this case instead of falling
into SCH_MainLoop and waiting there.
If that wasn't the expectation then we might be good - the
initially reported test issues are fixed - thanks!



> If you would like, I think it could be improved to prepare an rtcfile
> and look for the "System clock off from RTC" message when hwclock
> doesn't report that interrupts are not supported.
>
> --
> Miroslav Lichvar
>
>
> --
> To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with
> "unsubscribe" in the subject.
> For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the
> subject.
> Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.
>
>

-- 
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

--0000000000006a68a105996f1395
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Tue, Dec 10, 2019 at 5:59 PM Miros=
lav Lichvar &lt;<a href=3D"mailto:mlichvar@xxxxxxxxxx";>mlichvar@xxxxxxxxxx<=
/a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">O=
n Tue, Dec 10, 2019 at 04:25:31PM +0100, Christian Ehrhardt wrote:<br>
&gt; On Tue, Dec 10, 2019 at 4:19 PM Miroslav Lichvar &lt;<a href=3D"mailto=
:mlichvar@xxxxxxxxxx" target=3D"_blank">mlichvar@xxxxxxxxxx</a>&gt;<br>
&gt; &gt; I&#39;m sorry for changing my mind, but I now think this case sho=
uld be<br>
&gt; &gt; handled gracefully in chronyd and not avoided in the test. Accord=
ing<br>
&gt; &gt; to the man page, the -s option is supposed to work even with no R=
TC or<br>
&gt; &gt; broken RTCs. A hang or fatal error with the -s option may break<b=
r>
&gt; &gt; the user&#39;s expectation.<br>
&gt; &gt;<br>
&gt; &gt; Do you agree?<br>
&gt; &gt;<br>
&gt; <br>
&gt; Yes, but I think the changes are not mutually exclusive and should bot=
h be<br>
&gt; added.<br>
&gt; <br>
&gt; -s needs the change you suggested to make the fail fatal.<br>
<br>
As I tried to explain in the later post, I think chronyd -s should not<br>
fail if the RTC doesn&#39;t support interrupts, as the documentation<br>
implies chronyd can work with &quot;broken&quot; RTCs and we shouldn&#39;t =
expect<br>
the users to test it before configuring chronyd.<br>
<br>
&gt; Otherwise users will not realize that they don&#39;t get what they ord=
ered.<br>
<br>
There will still be the error message in the log.<br>
<br>
Can you please try the test again with the latest code?<br></blockquote><di=
v><br></div><div>I tested with the current head being commit f5eb7daf &quot=
;rtc: disable interrupts in finalization&quot;<br><br>With that the test fi=
nally worked on the two affected platforms that I had:<br>./run -d 103-refc=
lock <br>103-refclock =C2=A0 Testing reference clocks:<br>=C2=A0 non-defaul=
t settings:<br>=C2=A0 =C2=A0 extra_chronyd_directives=3D refclock SOCK /hom=
e/ubuntu/chrony/test/system/tmp/refclock.sock refclock SHM 100<br>=C2=A0 st=
arting chronyd =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0OK<br>=C2=A0 waiting for synchronization =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 OK<br>=C2=A0 stopping chronyd =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0OK<br>=C2=A0 checking chronyd messages =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 OK<br>=C2=A0 checking chronyd files =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0OK<br>PASS<br><br><br>S=
UMMARY:<br>=C2=A0 TOTAL =C2=A01<br>=C2=A0 PASSED 1<br>=C2=A0 FAILED 0 =C2=
=A0 =C2=A0()<br>=C2=A0 SKIPPED 0 =C2=A0 ()<br><br><br></div><div>But when r=
un in debug mode it still looks the same:<br>$ ./chronyd -d -s -f /root/chr=
onyd.conf<br>019-12-11T14:37:35Z chronyd version DEVELOPMENT starting (+CMD=
MON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER -SIGND +ASYNCDNS +SECHASH +IPV6=
 -DEBUG)<br>2019-12-11T14:37:36Z System time set from RTC<br>2019-12-11T14:=
37:36Z Initial frequency -13.014 ppm<br>2019-12-11T14:37:36Z Could not enab=
le RTC interrupt : Invalid argument<br><br>I&#39;d have expected a fatal ex=
it in these cases now - is that right?<br><br>From reading the (new) code I=
&#39;d expect RTC_Linux_Initialise to now detect the problem and return 0 f=
rom this new section:<br><br></div><div>+ =C2=A0/* Make sure the RTC suppor=
ts interrupts */<br>+ =C2=A0if (!switch_interrupts(0)) {<br>+ =C2=A0 =C2=A0=
close(fd);<br>+ =C2=A0 =C2=A0return 0;<br>+ =C2=A0}<br><br>But what I see h=
appening is this:<br><br>gdb) b RTC_Finalise<br>Breakpoint 1 at 0x11bc8: fi=
le rtc.c, line 162.<br>(gdb) b RTC_Initialise<br>Breakpoint 2 at 0x119b8: f=
ile rtc.c, line 115.<br>(gdb) b RTC_Linux_Initialise<br>Breakpoint 3 at 0x3=
73e8: file rtc_linux.c, line 509.<br>(gdb) b switch_interrupts<br>Breakpoin=
t 4 at 0x36d28: switch_interrupts. (2 locations)<br>(gdb) run -d -s -f /roo=
t/chronyd.conf<br>Starting program: /home/ubuntu/chrony/chronyd -d -s -f /r=
oot/chronyd.conf<br>[Thread debugging using libthread_db enabled]<br>Using =
host libthread_db library &quot;/lib/powerpc64le-linux-gnu/libthread_db.so.=
1&quot;.<br>2019-12-11T14:43:05Z chronyd version DEVELOPMENT starting (+CMD=
MON +NTP +REFCLOCK +RTC +PRIVDROP -SCFILTER -SIGND +ASYNCDNS +SECHASH +IPV6=
 -DEBUG)<br>2019-12-11T14:43:05Z Wrong owner of /var/run/chrony (UID !=3D 0=
)<br>2019-12-11T14:43:05Z Disabled command socket /var/run/chrony/chronyd.s=
ock<br><br>Breakpoint 2, 0x00000001000119b8 in RTC_Initialise (initial_set=
=3D1) at rtc.c:115<br>115 =C2=A0 =C2=A0 {<br>(gdb) n<br>125 =C2=A0 =C2=A0 =
=C2=A0 if (initial_set) {<br>(gdb) <br>126 =C2=A0 =C2=A0 =C2=A0 =C2=A0 drif=
tfile_time =3D get_driftfile_time();<br>(gdb) <br>128 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 if (driver.time_pre_init &amp;&amp; driver.time_pre_init(driftfile_t=
ime)) {<br>(gdb) <br>129 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 driver_preinit_=
ok =3D 1;<br>(gdb) <br>137 =C2=A0 =C2=A0 =C2=A0 driver_initialised =3D 0;<b=
r>(gdb) <br>141 =C2=A0 =C2=A0 =C2=A0 file_name =3D CNF_GetRtcFile();<br>(gd=
b) <br>143 =C2=A0 =C2=A0 =C2=A0 if (file_name) {<br>(gdb) <br>144 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 if (CNF_GetRtcSync()) {<br>(gdb) <br>149 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 if ((driver.init)()) {<br>(gdb) <br>Breakpoint 3, 0x0=
0000001000373e8 in RTC_Linux_Initialise () at rtc_linux.c:509<br>509 =C2=A0=
 =C2=A0 {<br>(gdb) <br>511 =C2=A0 =C2=A0 =C2=A0 fd =3D open(CNF_GetRtcDevic=
e(), O_RDWR);<br>(gdb) <br>512 =C2=A0 =C2=A0 =C2=A0 if (fd &lt; 0) {<br>(gd=
b) <br>519 =C2=A0 =C2=A0 =C2=A0 if (!switch_interrupts(0)) {<br>(gdb) <br>B=
reakpoint 4, 0x0000000100036d28 in switch_interrupts (on_off=3D0) at rtc_li=
nux.c:489<br>489 =C2=A0 =C2=A0 {<br>(gdb) <br>490 =C2=A0 =C2=A0 =C2=A0 if (=
ioctl(fd, on_off ? RTC_UIE_ON : RTC_UIE_OFF, 0) &lt; 0) {<br>(gdb) <br>RTC_=
Linux_Initialise () at rtc_linux.c:525<br>525 =C2=A0 =C2=A0 =C2=A0 UTI_FdSe=
tCloexec(fd);<br>(gdb) <br>527 =C2=A0 =C2=A0 =C2=A0 rtc_sec =3D MallocArray=
(time_t, MAX_SAMPLES);<br>(gdb) <br>528 =C2=A0 =C2=A0 =C2=A0 rtc_trim =3D M=
allocArray(double, MAX_SAMPLES);<br>(gdb) <br>529 =C2=A0 =C2=A0 =C2=A0 syst=
em_times =3D MallocArray(struct timespec, MAX_SAMPLES);<br>(gdb) <br>532 =
=C2=A0 =C2=A0 =C2=A0 setup_config();<br>(gdb) <br>535 =C2=A0 =C2=A0 =C2=A0 =
coefs_file_name =3D CNF_GetRtcFile();<br>(gdb) <br>537 =C2=A0 =C2=A0 =C2=A0=
 n_samples =3D 0;<br>(gdb) <br>538 =C2=A0 =C2=A0 =C2=A0 n_samples_since_reg=
ression =3D 0;<br>(gdb) <br>539 =C2=A0 =C2=A0 =C2=A0 n_runs =3D 0;<br>(gdb)=
 <br>540 =C2=A0 =C2=A0 =C2=A0 coefs_valid =3D 0;<br>(gdb) <br>547 =C2=A0 =
=C2=A0 =C2=A0 SCH_AddFileHandler(fd, SCH_FILE_INPUT, read_from_device, NULL=
);<br>(gdb) <br>550 =C2=A0 =C2=A0 =C2=A0 LCL_AddParameterChangeHandler(slew=
_samples, NULL);<br>(gdb) <br>552 =C2=A0 =C2=A0 =C2=A0 logfileid =3D CNF_Ge=
tLogRtc() ? LOG_FileOpen(&quot;rtc&quot;,<br>(gdb) <br>555 =C2=A0 =C2=A0 =
=C2=A0 return 1;<br>(gdb) <br>RTC_Initialise (initial_set=3D&lt;optimized o=
ut&gt;) at rtc.c:150<br>150 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 drive=
r_initialised =3D 1;<br>(gdb) <br>main (argc=3D&lt;optimized out&gt;, argv=
=3D0x7ffffffff558) at main.c:555<br>555 =C2=A0 =C2=A0 =C2=A0 SRC_Initialise=
();<br>(gdb) <br>556 =C2=A0 =C2=A0 =C2=A0 RCL_Initialise();<br>(gdb) <br>55=
7 =C2=A0 =C2=A0 =C2=A0 KEY_Initialise();<br>(gdb) <br>558 =C2=A0 =C2=A0 =C2=
=A0 SCK_Initialise();<br>(gdb) <br>561 =C2=A0 =C2=A0 =C2=A0 CAM_Initialise(=
address_family);<br>(gdb) <br>562 =C2=A0 =C2=A0 =C2=A0 NIO_Initialise(addre=
ss_family);<br>(gdb) <br>563 =C2=A0 =C2=A0 =C2=A0 NCR_Initialise();<br>(gdb=
) <br>564 =C2=A0 =C2=A0 =C2=A0 CNF_SetupAccessRestrictions();<br>(gdb) <br>=
567 =C2=A0 =C2=A0 =C2=A0 if (!sched_priority) {<br>(gdb) <br>568 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 sched_priority =3D CNF_GetSchedPriority();<br>(gdb) <br>5=
70 =C2=A0 =C2=A0 =C2=A0 if (sched_priority) {<br>(gdb) <br>574 =C2=A0 =C2=
=A0 =C2=A0 if (lock_memory || CNF_GetLockMemory()) {<br>(gdb) <br>579 =C2=
=A0 =C2=A0 =C2=A0 if (!geteuid() &amp;&amp; (pw-&gt;pw_uid || pw-&gt;pw_gid=
))<br>(gdb) <br>582 =C2=A0 =C2=A0 =C2=A0 REF_Initialise();<br>(gdb) <br>201=
9-12-11T14:43:52Z Initial frequency -21.507 ppm<br>583 =C2=A0 =C2=A0 =C2=A0=
 SST_Initialise();<br>(gdb) <br>584 =C2=A0 =C2=A0 =C2=A0 NSR_Initialise();<=
br>(gdb) <br>585 =C2=A0 =C2=A0 =C2=A0 NSD_Initialise();<br>(gdb) <br>586 =
=C2=A0 =C2=A0 =C2=A0 CLG_Initialise();<br>(gdb) <br>587 =C2=A0 =C2=A0 =C2=
=A0 MNL_Initialise();<br>(gdb) <br>588 =C2=A0 =C2=A0 =C2=A0 TMC_Initialise(=
);<br>(gdb) <br>589 =C2=A0 =C2=A0 =C2=A0 SMT_Initialise();<br>(gdb) <br>592=
 =C2=A0 =C2=A0 =C2=A0 initialised =3D 1;<br>(gdb) <br>594 =C2=A0 =C2=A0 =C2=
=A0 UTI_SetQuitSignalsHandler(signal_cleanup, 1);<br>(gdb) <br>596 =C2=A0 =
=C2=A0 =C2=A0 CAM_OpenUnixSocket();<br>(gdb) <br>598 =C2=A0 =C2=A0 =C2=A0 i=
f (scfilter_level)<br>(gdb) <br>601 =C2=A0 =C2=A0 =C2=A0 if (ref_mode =3D=
=3D REF_ModeNormal &amp;&amp; CNF_GetInitSources() &gt; 0) {<br>(gdb) <br>6=
05 =C2=A0 =C2=A0 =C2=A0 REF_SetModeEndHandler(reference_mode_end);<br>(gdb)=
 <br>606 =C2=A0 =C2=A0 =C2=A0 REF_SetMode(ref_mode);<br>(gdb) <br>608 =C2=
=A0 =C2=A0 =C2=A0 if (timeout &gt; 0)<br>(gdb) <br>611 =C2=A0 =C2=A0 =C2=A0=
 if (do_init_rtc) {<br>(gdb) <br>612 =C2=A0 =C2=A0 =C2=A0 =C2=A0 RTC_TimeIn=
it(post_init_rtc_hook, NULL);<br>(gdb) <br>Breakpoint 4, 0x0000000100036d28=
 in switch_interrupts (on_off=3D1) at rtc_linux.c:489<br>489 =C2=A0 =C2=A0 =
{<br>(gdb) <br>490 =C2=A0 =C2=A0 =C2=A0 if (ioctl(fd, on_off ? RTC_UIE_ON :=
 RTC_UIE_OFF, 0) &lt; 0) {<br>(gdb) <br>488 =C2=A0 =C2=A0 switch_interrupts=
(int on_off)<br>(gdb) <br>2019-12-11T14:44:14Z Could not enable RTC interru=
pt : Invalid argument<br>main (argc=3D&lt;optimized out&gt;, argv=3D0x7ffff=
ffff558) at main.c:619<br>619 =C2=A0 =C2=A0 =C2=A0 SCH_MainLoop();<br>(gdb)=
<br>&lt;hang&gt;<br><br><br><br>The latter part in more detail:<br><br>612 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 RTC_TimeInit(post_init_rtc_hook, NULL);<br>(gdb=
) s<br>RTC_TimeInit (after_hook=3D0x10000cb60 &lt;post_init_rtc_hook&gt;, a=
nything=3D0x0) at rtc.c:182<br>182 =C2=A0 =C2=A0 =C2=A0 if (driver_initiali=
sed &amp;&amp; driver_preinit_ok) {<br>(gdb) n<br>183 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 (driver.time_init)(after_hook, anything);<br>(gdb) s<br>RTC_Linux_Ti=
meInit (after_hook=3D0x10000cb60 &lt;post_init_rtc_hook&gt;, anything=3D0x0=
) at rtc_linux.c:885<br>885 =C2=A0 =C2=A0 =C2=A0 after_init_hook =3D after_=
hook;<br>(gdb) n<br>886 =C2=A0 =C2=A0 =C2=A0 after_init_hook_arg =3D anythi=
ng;<br>(gdb) n<br>888 =C2=A0 =C2=A0 =C2=A0 operating_mode =3D OM_INITIAL;<b=
r>(gdb) n<br>889 =C2=A0 =C2=A0 =C2=A0 timeout_id =3D 0;<br>(gdb) n<br>890 =
=C2=A0 =C2=A0 =C2=A0 switch_interrupts(1);<br>(gdb) n<br>Breakpoint 4, 0x00=
00000100036d28 in switch_interrupts (on_off=3D1) at rtc_linux.c:489<br>489 =
=C2=A0 =C2=A0 {<br>(gdb) bt<br>#0 =C2=A00x0000000100036d28 in switch_interr=
upts (on_off=3D1) at rtc_linux.c:489<br>#1 =C2=A00x0000000100011c74 in RTC_=
TimeInit (after_hook=3D&lt;optimized out&gt;, anything=3D&lt;optimized out&=
gt;) at rtc.c:183<br>#2 =C2=A00x0000000100004878 in main (argc=3D&lt;optimi=
zed out&gt;, argv=3D0x7ffffffff558) at main.c:612<br><br><br>That means the=
 first switch_interrupts call from RTC_Initialise -&gt; RTC_Linux_Initialis=
e -&gt; switch_interrupts has on_off=3D0 and that doesn&#39;t trigger the i=
ssue at initialization phase.<br>Later on on RTC_TimeInit -&gt; switch_inte=
rrupts argument on_off=3D1 and the issue occurs.<br>Turns out our &quot;pro=
blematic&quot; RTCs only trigger the issue on on_off=3D1.<br>Can we safely =
set that to 1 in the check like?<br><br>diff --git a/rtc_linux.c b/rtc_linu=
x.c<br>index aee768f..b1eee19 100644<br>--- a/rtc_linux.c<br>+++ b/rtc_linu=
x.c<br>@@ -516,7 +516,7 @@ RTC_Linux_Initialise(void)<br>=C2=A0 =C2=A0}<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C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C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0<br>=C2=A0 =C2=A0}<br><br>Or do we need some cod=
e to then revert that setting immediately to be on the safe side?<br><br>di=
ff --git a/rtc_linux.c b/rtc_linux.c<br>index aee768f..8d0fae5 100644<br>--=
- a/rtc_linux.c<br>+++ b/rtc_linux.c<br>@@ -516,7 +516,7 @@ RTC_Linux_Initi=
alise(void)<br>=C2=A0 =C2=A0}<br>=C2=A0<br>=C2=A0 =C2=A0/* Make sure the RT=
C supports interrupts */<br>- =C2=A0if (!switch_interrupts(0)) {<br>+ =C2=
=A0if (!switch_interrupts(1) || switch_interrupts(0)) {<br>=C2=A0 =C2=A0 =
=C2=A0close(fd);<br>=C2=A0 =C2=A0 =C2=A0return 0;<br>=C2=A0 =C2=A0}<br><br>=
Maybe even something with a harder implication on the order those are execu=
ted.<br>I tested the second of the above and it did now trigger the issue w=
hen called from RTC_Linux_Initialise.</div><div>It also did not set driver_=
initialised=3D1 this time.<br><br><br>Now it behaves more like expected:<br=
>Breakpoint 3, 0x00000001000373e8 in RTC_Linux_Initialise () at rtc_linux.c=
:509<br>509 =C2=A0 =C2=A0 {<br>(gdb) n<br>511 =C2=A0 =C2=A0 =C2=A0 fd =3D o=
pen(CNF_GetRtcDevice(), O_RDWR);<br>(gdb) <br>512 =C2=A0 =C2=A0 =C2=A0 if (=
fd &lt; 0) {<br>(gdb) <br>519 =C2=A0 =C2=A0 =C2=A0 if (!switch_interrupts(1=
) || switch_interrupts(0)) {<br>(gdb) <br><br>Breakpoint 2, 0x0000000100036=
d28 in switch_interrupts (on_off=3D1) at rtc_linux.c:489<br>489 =C2=A0 =C2=
=A0 {<br>(gdb) n<br>490 =C2=A0 =C2=A0 =C2=A0 if (ioctl(fd, on_off ? RTC_UIE=
_ON : RTC_UIE_OFF, 0) &lt; 0) {<br>(gdb) n<br>488 =C2=A0 =C2=A0 switch_inte=
rrupts(int on_off)<br>(gdb) <br>2019-12-11T14:58:46Z Could not enable RTC i=
nterrupt : Invalid argument<br>RTC_Linux_Initialise () at rtc_linux.c:520<b=
r>520 =C2=A0 =C2=A0 =C2=A0 =C2=A0 close(fd);<br>(gdb) n<br>521 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 return 0;<br><br><br>Nevertheless it hangs eventually in =
this mode.<br>This is due to SCH_MainLoop begin the one with the select cal=
l where nothing returns.<br><br>Program received signal SIGINT, Interrupt.<=
br>0x00007ffff7c40864 in __GI___select (nfds=3D514, readfds=3D0x7fffffffede=
8, writefds=3D0x0, exceptfds=3D0x0, timeout=3D0x0) at ../sysdeps/unix/sysv/=
linux/select.c:41<br>41 =C2=A0 =C2=A0 =C2=A0../sysdeps/unix/sysv/linux/sele=
ct.c: No such file or directory.<br>(gdb) bt<br>#0 =C2=A00x00007ffff7c40864=
 in __GI___select (nfds=3D514, readfds=3D0x7fffffffede8, writefds=3D0x0, ex=
ceptfds=3D0x0, timeout=3D0x0) at ../sysdeps/unix/sysv/linux/select.c:41<br>=
#1 =C2=A00x0000000100014440 in SCH_MainLoop () at sched.c:753<br>#2 =C2=A00=
x0000000100004880 in main (argc=3D&lt;optimized out&gt;, argv=3D0x7ffffffff=
558) at main.c:619<br><br>I&#39;ve understood that you wanted it to hard-fa=
il and bail out of -s was set but RTC init failed right?<br></div><div>Ther=
efore I&#39;d have expected an exit in this case instead of falling into=C2=
=A0SCH_MainLoop and waiting there.</div><div>If that wasn&#39;t the expecta=
tion then we might be good - the initially=C2=A0reported test issues are fi=
xed - thanks!</div><div><br></div><div>=C2=A0</div><blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,2=
04,204);padding-left:1ex">
If you would like, I think it could be improved to prepare an rtcfile<br>
and look for the &quot;System clock off from RTC&quot; message when hwclock=
<br>
doesn&#39;t report that interrupts are not supported.<br>
<br>
-- <br>
Miroslav Lichvar<br>
<br>
<br>
-- <br>
To unsubscribe email <a href=3D"mailto:chrony-dev-request@xxxxxxxxxxxxxxxx.=
org" target=3D"_blank">chrony-dev-request@xxxxxxxxxxxxxxxxxxxx</a> with &qu=
ot;unsubscribe&quot; in the subject.<br>
For help email <a href=3D"mailto:chrony-dev-request@xxxxxxxxxxxxxxxxxxxx"; t=
arget=3D"_blank">chrony-dev-request@xxxxxxxxxxxxxxxxxxxx</a> with &quot;hel=
p&quot; in the subject.<br>
Trouble?=C2=A0 Email <a href=3D"mailto:listmaster@xxxxxxxxxxxxxxxxxxxx"; tar=
get=3D"_blank">listmaster@xxxxxxxxxxxxxxxxxxxx</a>.<br>
<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature">Christian Ehrhardt<br>Staff Engineer, Ubuntu Ser=
ver<br>Canonical Ltd</div></div>

--0000000000006a68a105996f1395--

-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/