[Bug 1269803] Re: C++ standard library is compiled with nanosleep and yield switched OFF

Denys Rtveliashvili rtvd at me.com
Thu Jan 16 13:47:54 UTC 2014


To be clear, gcc-4.6 is affected starting from gcc-4.6.4. gcc-4.6.3 which comes with Ubuntu 12.04 LTS is still good.
Also, gcc-4.7 and gcc-4.8 are affected.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.6 in Ubuntu.
https://bugs.launchpad.net/bugs/1269803

Title:
  C++ standard library is compiled with nanosleep and yield switched OFF

Status in “gcc-4.6” package in Ubuntu:
  New

Bug description:
  INTRODUCTION
  --------------------------

  The C++ library has internal macros called _GLIBCXX_USE_NANOSLEEP and
  _GLIBCXX_USE_SCHED_YIELD.

  Normally the macros are defined in x86_64-linux-
  gnu/32/bits/c++config.h and x86_64-linux-gnu/bits/c++config.h.

  When _GLIBCXX_USE_NANOSLEEP is defined, the standard library has
  support for crucial components related to time.

  Specifically, in "thread" there is a section which begins with "#ifdef
  _GLIBCXX_USE_NANOSLEEP" and declares "sleep_until", "sleep_for",
  "nanosleep", "chrono::seconds",  "chrono::nanoseconds", etc. There
  functions / types are an important part of C++ standard.

  The _GLIBCXX_USE_SCHED_YIELD macro enables "yield()" method.

  PROBLEM
  --------------------------

  C++ code which depends on the relevant parts of the C++ standard simply cannot be compiled.
  There is no known and reliable workaround for this problem.

  WHY IT HAPPENED
  --------------------------
  I am not 100% sure, but there seem to be a bug in a test program which check for the presence of nanosleep. It is a part of "configure", which is in turn generated from acinclude.m4.

  In order to test for nanosleep the following program is used:

  #include <unistd.h>
     #include <time.h>

  int
  main ()
  {
  #if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
      timespec tp;
     #endif
      clock_gettime(CLOCK_MONOTONIC, &tp);

    ;
    return 0;
  }

  The program is missing "struct" before "timespec tp;". In fact, there
  are three places in the file where the "struct" is missing.

  As for "yield", I am not sure yet why it is missing but the reason is
  probably similar.

  SCOPE
  --------------------------
  Both macros are NOT enabled in Ubuntu releases after 12.04 LTS, including the to-be-released Ubuntu 14.04 LTS.

  For example, on Ubuntu 13.10:

   rtvd at localhost $ pwd
   
   /usr/include/c++
   
   rtvd at localhost $ grep -r _GLIBCXX_USE_NANOSLEEP *
   
   4.6/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.6/x86_64-linux-gnu/32/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
   4.6/x86_64-linux-gnu/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
   4.6.4/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.6.4/x86_64-linux-gnu/32/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
   4.6.4/x86_64-linux-gnu/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
   4.7/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.7.3/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.8/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.8.1/thread:#ifdef _GLIBCXX_USE_NANOSLEEP

  On Ubuntu 12.04 LTS (notice #define ...) everything is good:

   rtvd at localhost $ pwd

   /usr/include/c++

   rtvd at localhost $ grep -r _GLIBCXX_USE_NANOSLEEP *

   4.6/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.6.3/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6.3/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6.3/thread:#ifdef _GLIBCXX_USE_NANOSLEEP

  On Debian 7.3 the macros are defined (notice #define ... in each
  version of the library), so C++ library is good there too:

   rtvd at debiantest:/usr/include/c++$ pwd
   
   /usr/include/c++
   
   rtvd at debiantest:/usr/include/c++$ grep -r _GLIBCXX_USE_NANOSLEEP *
   
   4.6/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.6.3/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6.3/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.6.3/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.7/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.7/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.7/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
   4.7.2/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.7.2/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
   4.7.2/thread:#ifdef _GLIBCXX_USE_NANOSLEEP

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.6/+bug/1269803/+subscriptions



More information about the foundations-bugs mailing list