From: Sebastian Kemper <sebastian_ml@gmx.net>
To: musl@lists.openwall.com, Szabolcs Nagy <nsz@port70.net>
Cc: "Érico Nogueira" <ericonr@disroot.org>
Subject: Re: [musl] Re: freeswitch and musl 1.2.x (time64 most likely)
Date: Sat, 30 Oct 2021 00:44:05 +0200 [thread overview]
Message-ID: <YXx5Ncu7Of5bsfCM@darth.lan> (raw)
In-Reply-To: <20211029210445.GT37904@port70.net>
Am Fri, Oct 29, 2021 at 11:04:45PM +0200 schrieb Szabolcs Nagy:
> * Sebastian Kemper <sebastian_ml@gmx.net> [2021-10-29 16:40:02 +0200]:
> > (gdb) p current
> > $1 = 193277741781
> > (gdb) p ¤t
> > $2 = (apr_time_t *) 0x7fffac90
> > (gdb) p os_now
> > $3 = 19521141760827868
> > (gdb) p &os_now
> > $4 = (time_t *) 0x7fffac88
> > (gdb) p timediff
> > $5 = 19521141756395521
>
> these values are completely wrong (may be not set up yet,
> you cannot rely on line numbers in optimized code)
>
> time on your system now should be around
>
> 1635500000
>
> current / 1000000 is
>
> 193277
>
> which is 1970-01-03 05:41:17
>
> os_now is far in the future.
>
Hello Szabolcs,
I changed the test program a little bit:
--- a/test/testtime.c
+++ b/test/testtime.c
@@ -21,6 +21,7 @@
#include "testutil.h"
#include "apr_strings.h"
#include <time.h>
+#include <stdio.h>
#define STR_SIZE 45
@@ -57,6 +58,7 @@ static void test_now(abts_case *tc, void
apr_time_t timediff;
apr_time_t current;
time_t os_now;
+ struct tm * timeinfo;
current = apr_time_now();
time(&os_now);
@@ -66,6 +68,10 @@ static void test_now(abts_case *tc, void
* that the time will be slightly off, so accept anything between -1 and
* 1 second.
*/
+ timeinfo = localtime ( &os_now );
+ printf ( "Current local time and date: %s - %lld seconds since epoch\n", asctime (timeinfo), os_now);
+ timeinfo = localtime ( ¤t );
+ printf ( "Current APR time and date: %s - %lld seconds since epoch\n", asctime (timeinfo), current);
ABTS_ASSERT(tc, "apr_time and OS time do not agree",
(timediff > -2) && (timediff < 2));
}
The output is:
Current local time and date: Sat Oct 30 00:25:11 2021 - 7024617916842658549 seconds since epoch
Current APR time and date: Mon Jan 5 10:46:45 1970 - 1635546302107561 seconds since epoch
|Line 76: apr_time and OS time do not agree
(gdb) b time
Breakpoint 1 at 0x77fd0b08: file compat/time32/time32.c, line 7.
(gdb) b gettimeofday
Breakpoint 2 at 0x77fcff6c: file compat/time32/gettimeofday_time32.c, line 7.
(gdb) b apr_time_now
Function "apr_time_now" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 3 (apr_time_now) pending.
(gdb) c
Continuing.
Breakpoint 1, time (p=0x7fffac90) at compat/time32/time32.c:7
7 {
(gdb) next
8 time_t t = time(0);
(gdb)
9 if (t < INT32_MIN || t > INT32_MAX) {
(gdb)
13 if (p) *p = t;
(gdb)
14 return t;
(gdb)
test_now (tc=0x7fffacd0, data=0x0) at testtime.c:66
66 timediff = os_now - (current / APR_USEC_PER_SEC);
(gdb) p os_now
$1 = 7024617916842658549
(gdb) p current
$2 = 1635546302107561
(gdb) p APR_USEC_PER_SEC
$3 = 1000000
(gdb) c
Continuing.
[Inferior 1 (process 15506) exited with code 01]
So OS time is correct. Something not working right with apr.
> > (gdb) p &timediff
> > $6 = (apr_time_t *) 0x7fffac98
> > (gdb) p time
> > $7 = {time32_t (time32_t *)} 0x77fd0b08 <time>
> > (gdb) p &time
> > $8 = (time32_t (*)(time32_t *)) 0x77fd0b08 <time>
> > (gdb) c
> > Continuing.
> > [Inferior 1 (process 14739) exited with code 01]
> > (gdb)
> >
> > To me it looks like apr is also using a 64 bit type for time. So it's a
> > bit of a surprise for me that there is a problem. I find it also strange
> > that the time function (which seems to be from libc) seems to be related
> > to a 32 bit type.
> >
> > Can you maybe make sense of this?
>
> you need to debug this further, all sorts of things may be wrong here.
>
> i'd remove all other tests from the test exe and break on gettimeofday
> and time and see what the libc returns, also print the time in the test.
next prev parent reply other threads:[~2021-10-29 22:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 22:16 [musl] " Sebastian Kemper
2021-10-27 23:24 ` Érico Nogueira
2021-10-28 20:21 ` [musl] " Sebastian Kemper
2021-10-28 21:34 ` Sebastian Kemper
2021-10-29 3:10 ` Érico Nogueira
2021-10-29 14:40 ` Sebastian Kemper
2021-10-29 21:04 ` Szabolcs Nagy
2021-10-29 22:44 ` Sebastian Kemper [this message]
2021-10-30 1:00 ` Rich Felker
2021-10-30 10:57 ` Sebastian Kemper
2021-10-30 17:56 ` Rich Felker
2021-10-30 19:07 ` Sebastian Kemper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YXx5Ncu7Of5bsfCM@darth.lan \
--to=sebastian_ml@gmx.net \
--cc=ericonr@disroot.org \
--cc=musl@lists.openwall.com \
--cc=nsz@port70.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).