Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 14 Apr 2014 12:16:15 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: gettimeofday

* John Mudd <johnbmudd@...il.com> [2014-04-13 22:03:10 -0400]:
> I ran into trouble when I built Postgres using musl on a modern Linux and
> tried to run it on an old Linux. The problem seemed to
> involve gettimeofday() so I tried this sample program.
...
> $ strace test_time
> execve("/home/jmudd/musl/test_time", ["test_time"], [/* 27 vars */]) = 0
> clock_gettime(0, 0xbfffae48)            = -1 ENOSYS (Function not
> implemented)
> gettimeofday(NULL, {300, 0})            = 0
> ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
> writev(1, [{"gettimeofday() successful.", 26}, {"\n", 1}], 2gettimeofday()
> successful.
> ) = 27
> writev(1, [{"time = 300.000000", 17}, {"\n", 1}], 2time = 300.000000
> ) = 18

this is a bug in the (untested) clock_gettime fallback code
here is a fix:

diff --git a/src/time/clock_gettime.c b/src/time/clock_gettime.c
index ad5c09d..ce9f220 100644
--- a/src/time/clock_gettime.c
+++ b/src/time/clock_gettime.c
@@ -10,7 +10,7 @@ static int sc_clock_gettime(clockid_t clk, struct timespec *ts)
        if (!r) return r;
        if (r == -ENOSYS) {
                if (clk == CLOCK_REALTIME) {
-                       __syscall(SYS_gettimeofday, clk, ts, 0);
+                       __syscall(SYS_gettimeofday, ts, 0);
                        ts->tv_nsec = (int)ts->tv_nsec * 1000;
                        return 0;
                }

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.