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
#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
Description: This is a digitally signed message part

