nanosleep broken on ~amd64?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

nanosleep broken on ~amd64?

walter s
By accident I noticed that the configure script for one of the gentoo
packages (I think maybe it was coreutils but I can't remember) gives
different results on ~x86 and ~amd64.

The script uses a "test for working nanosleep" that I've included below.

Could someone else compile the test and confirm that it returns 119 on
~amd64 instead of 0?

Here are the steps if you don't already know them:
1. Copy and paste the c code below into a new file named conftest.c
2. # gcc conftest.c
3. # ./a.out  (don't forget that leading dot)
4. # echo $? (this should print either 0 or 119)

I get 119 on ~amd64, which implies the test for nanosleep fails.

Thanks!


Here are the contents of conftest.c:

         #include <errno.h>
         #include <limits.h>
         #include <signal.h>
         #include <sys/time.h>
         #include <time.h>
         #include <unistd.h>
         #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
         #define TYPE_MAXIMUM(t) ((t) (! TYPE_SIGNED (t) ? (t) -1 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))

         static void
         check_for_SIGALRM (int sig)
         {
           if (sig != SIGALRM)
             _exit (1);
         }

         int
         main ()
         {
           static struct timespec ts_sleep;
           static struct timespec ts_remaining;
           static struct sigaction act;
           if (! nanosleep)
             return 1;
           act.sa_handler = check_for_SIGALRM;
           sigemptyset (&act.sa_mask);
           sigaction (SIGALRM, &act, NULL);
           ts_sleep.tv_sec = 0;
           ts_sleep.tv_nsec = 1;
           alarm (1);
           if (nanosleep (&ts_sleep, NULL) != 0)
             return 1;
           ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
           ts_sleep.tv_nsec = 999999999;
           alarm (1);
           if (nanosleep (&ts_sleep, &ts_remaining) == -1 && errno == EINTR
               && TYPE_MAXIMUM (time_t) - 10 < ts_remaining.tv_sec)
             return 0;
           return 119;
         }


Reply | Threaded
Open this post in threaded view
|

Re: nanosleep broken on ~amd64?

Peter Alfredsen-3
On Sun, 03 May 2009 14:14:38 -0700
walt <[hidden email]> wrote:

> By accident I noticed that the configure script for one of the gentoo
> packages (I think maybe it was coreutils but I can't remember) gives
> different results on ~x86 and ~amd64.
>
> The script uses a "test for working nanosleep" that I've included
> below.
>
> Could someone else compile the test and confirm that it returns 119 on
> ~amd64 instead of 0?

~amd64, returns 119

/loki_val

Reply | Threaded
Open this post in threaded view
|

Re: nanosleep broken on ~amd64?

Arttu V.-2
In reply to this post by walter s
walt wrote:
> Could someone else compile the test and confirm that it returns 119 on
> ~amd64 instead of 0?

It returns 119 on an semi-ancient Athlon64 3200+ box here as well.

Could kernel HZ-settings affect the outcome? This box has CONFIG_HZ=250,
but tomorrow I can try on another amd64 which runs a 1000HZ kernel IIRC.

--
Arttu V.

Reply | Threaded
Open this post in threaded view
|

Re: nanosleep broken on ~amd64?

Nikos Chantziaras
Arttu V. wrote:
> walt wrote:
>> Could someone else compile the test and confirm that it returns 119 on
>> ~amd64 instead of 0?
>
> It returns 119 on an semi-ancient Athlon64 3200+ box here as well.
>
> Could kernel HZ-settings affect the outcome? This box has CONFIG_HZ=250,
> but tomorrow I can try on another amd64 which runs a 1000HZ kernel IIRC.

119 here on AMD64 with a not-so-ancient Core 2 Duo and a kernel timer of
1000Hz (gentoo-sources-2.6.28-r5).


Reply | Threaded
Open this post in threaded view
|

Re: nanosleep broken on ~amd64?

Paul Hartman-3
In reply to this post by Arttu V.-2
On Sun, May 3, 2009 at 5:48 PM, Arttu V. <[hidden email]> wrote:
> walt wrote:
>>
>> Could someone else compile the test and confirm that it returns 119 on
>> ~amd64 instead of 0?
>
> It returns 119 on an semi-ancient Athlon64 3200+ box here as well.
>
> Could kernel HZ-settings affect the outcome? This box has CONFIG_HZ=250, but
> tomorrow I can try on another amd64 which runs a 1000HZ kernel IIRC.

Also 119 here. I use NO_HZ option.

Also, ksystraycmd from KDE4 has segfault in nanosleep every time,
forever. Maybe it's related?

Reply | Threaded
Open this post in threaded view
|

Re: nanosleep broken on ~amd64?

Mike Kazantsev
In reply to this post by walter s
On Sun, 03 May 2009 14:14:38 -0700
walt <[hidden email]> wrote:

> Could someone else compile the test and confirm that it returns 119 on
> ~amd64 instead of 0?

119, x86_64 Intel(R) Xeon(R) CPU L5420 @ 2.50GHz GenuineIntel

--
Mike Kazantsev // fraggod.net

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: nanosleep broken on ~amd64?

Nikos Chantziaras
In reply to this post by Nikos Chantziaras
Nikos Chantziaras wrote:

> Arttu V. wrote:
>> walt wrote:
>>> Could someone else compile the test and confirm that it returns 119 on
>>> ~amd64 instead of 0?
>>
>> It returns 119 on an semi-ancient Athlon64 3200+ box here as well.
>>
>> Could kernel HZ-settings affect the outcome? This box has
>> CONFIG_HZ=250, but tomorrow I can try on another amd64 which runs a
>> 1000HZ kernel IIRC.
>
> 119 here on AMD64 with a not-so-ancient Core 2 Duo and a kernel timer of
> 1000Hz (gentoo-sources-2.6.28-r5).

OK, compiling with "gcc -m32 nanotest.c" (-m32 compiles it as 32-bit on
multilib Gentoo) returns 0.  Maybe a bug in glibc?