Bug#1128631: std::condition_variable::wait_for() broken on GNU/Hurd

Mattias Ellert <[email protected]> Sun, 22 Feb 2026 02:14:06 +0100
Newsgroups gmane.linux.debian.ports.hurd
Message-ID <5cfbc208cd8c53e073befeefd0ccdb42192a28de.camel__23245.2012410917$1771723056$gmane$org@physics.uu.se>
Package: src:gcc-15
Version: 15.2.0-13
Severity: serious
User: [email protected]
Usertags: hurd-i386
X-Debbugs-CC: [email protected] 

When the following code is compiled on Linux, it behaves as expected
and returns after 2 seconds.

#include <condition_variable>
#include <mutex>

int main() {
  std::condition_variable cv;
  std::mutex mx;  
  std::unique_lock<std::mutex> lk(mx);
  cv.wait_for(lk, std::chrono::seconds(2));
}

$ g++ -o wait_for wait_for.cxx
$ time ./wait_for 

real	0m2,002s
user	0m0,001s
sys	0m0,001s

However, when compiled on GNU/Hurd (Debian porterbox exodar.debian.net)
it hangs forever and must be forced to quit with ctrl-C.

ellert@exodar:~$ g++ -o wait_for wait_for.cxx -pthread
ellert@exodar:~$ ./wait_for 
^C

Replacing
  cv.wait_for(lk, std::chrono::seconds(2));
with
  cv.wait_until(lk, std::chrono::steady_clock::now() + std::chrono::seconds(2));

Gives the same result -- which is expected since these should be
equivalent according to the standard.

If   the system clock is used instead of the steady clock it works also
on GNU/Hurd:
  cv.wait_until(lk, std::chrono::system_clock::now() + std::chrono::seconds(2));

But this is not the proper fix for the problem.

This behaviour causes test failures during package builds on GNU/Hurd.

Mattias Ellert
wait_for.cxx (text/x-c++src, 364 B)
#include <condition_variable>
#include <mutex>

int main() {
  std::condition_variable cv;
  std::mutex mx;
  
  std::unique_lock<std::mutex> lk(mx);
  cv.wait_for(lk, std::chrono::seconds(2));
  // cv.wait_until(lk, std::chrono::steady_clock::now() + std::chrono::seconds(2));
  // cv.wait_until(lk, std::chrono::system_clock::now() + std::chrono::seconds(2));
}
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6hgwr99NQxrZ4RRS6K7C/zvhqUsFAmmaWF4ACgkQ6K7C/zvh
qUtk4xAAjX1stNNES5v/a2mDZUyyKRCvfTxY8evbDS4P0Lo37b3Ex8udauxNaWzy
aCbz/KrDZjzmO68NrwZMJTUEHNkVNA/HY4Tpz4PXF2bO39FsuB9g12f9Ee1PFnhj
7t6glVFV5dmSK+CSo0Ov+zAHeDcbTRIsgCOJUhxQp/9Ndoipr81enT8ccybMHONT
my2Zk5S4hT/krDx+c4hMH2+XhbsVB8jXcKh58sPErwQTXYw6kJBb3SFEXwM2XgfV
0muDJG2BJ5YeV3XsS9fZoT3aPjTKd83a5GqbmDkBLSxE1H4Ipd2YJemD/Zm7wNAd
NfI1ryw07uQSUhK+/tK/xGdfbrp/qAvYonarTrjt374f3/q0EtStYtLLdVJ3KsP4
AlmkSM0ttBYF1LkdhPH4qh9TMzlIYciIn1WzFG6wFhAOMoc+V/zqBoDbWex33nTU
EDf/EEymbPbCT68VQE9gY5WytwU2SF2JAUK21KuluWU3gdg7CQqagAGMqx9I18dp
YXbHMQc2n9nWSdwXACz6RFCz1WoycBDq8/LRO4vWX6yZJekiuRQCs0jaDtTks9y2
USzxbCKz6/caKKVTJqlnb/3o5C7kpQKLZS/nyuadeFULdp6anK+owhEdzb6p2noe
XSawb1Id9jd4jqq966mC2KHi3cfV+AeouiXjDsM1we1y0S6aS8U=
=iOXZ
-----END PGP SIGNATURE-----