[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2018-08-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Jonathan Wakely  changed:

   What|Removed |Added

   Target Milestone|7.4 |6.5

--- Comment #13 from Jonathan Wakely  ---
Fixed for 6.5 too.

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2018-08-08 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

--- Comment #12 from Jonathan Wakely  ---
Author: redi
Date: Wed Aug  8 15:40:41 2018
New Revision: 263420

URL: https://gcc.gnu.org/viewcvs?rev=263420=gcc=rev
Log:
PR libstdc++/68519 use native duration to avoid rounding errors

Backport from mainline
2017-12-14  Jonathan Wakely  

PR libstdc++/68519
* include/std/condition_variable (condition_variable::wait_for):
Convert duration to native clock's duration before addition.
* testsuite/30_threads/condition_variable/members/68519.cc: New test.

Added:
   
branches/gcc-6-branch/libstdc++-v3/testsuite/30_threads/condition_variable/members/68519.cc
Modified:
branches/gcc-6-branch/libstdc++-v3/ChangeLog
branches/gcc-6-branch/libstdc++-v3/include/std/condition_variable

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2018-08-07 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Jonathan Wakely  changed:

   What|Removed |Added

   Target Milestone|8.0 |7.4

--- Comment #11 from Jonathan Wakely  ---
Fixed for 7.4 too.

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2018-08-07 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

--- Comment #10 from Jonathan Wakely  ---
Author: redi
Date: Tue Aug  7 22:50:40 2018
New Revision: 263380

URL: https://gcc.gnu.org/viewcvs?rev=263380=gcc=rev
Log:
PR libstdc++/68519 use native duration to avoid rounding errors

Backport from mainline
2017-12-14  Jonathan Wakely  

PR libstdc++/68519
* include/std/condition_variable (condition_variable::wait_for):
Convert duration to native clock's duration before addition.
* testsuite/30_threads/condition_variable/members/68519.cc: New test.

Added:
   
branches/gcc-7-branch/libstdc++-v3/testsuite/30_threads/condition_variable/members/68519.cc
Modified:
branches/gcc-7-branch/libstdc++-v3/ChangeLog
branches/gcc-7-branch/libstdc++-v3/include/std/condition_variable

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2017-12-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Jonathan Wakely  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |8.0

--- Comment #9 from Jonathan Wakely  ---
Fixed for GCC 8.

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2017-12-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

--- Comment #8 from Jonathan Wakely  ---
Author: redi
Date: Thu Dec 14 20:41:52 2017
New Revision: 255665

URL: https://gcc.gnu.org/viewcvs?rev=255665=gcc=rev
Log:
PR libstdc++/68519 use native duration to avoid rounding errors

PR libstdc++/68519
* include/std/condition_variable (condition_variable::wait_for):
Convert duration to native clock's duration before addition.
* testsuite/30_threads/condition_variable/members/68519.cc: New test.

Added:
trunk/libstdc++-v3/testsuite/30_threads/condition_variable/members/68519.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/condition_variable

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2017-12-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

--- Comment #7 from Jonathan Wakely  ---
The problem is that duration doesn't have sufficient precision to
represent now+1s as a float (the value is the same as now)

#include 
constexpr std::chrono::seconds now(1513266095);
constexpr auto then = now + std::chrono::duration(1);
static_assert( now < then, "" );

The timed waiting functions would have to check for such rounding errors.

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2017-12-14 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Jonathan Wakely  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |redi at gcc dot gnu.org

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2017-12-11 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

--- Comment #6 from Jonathan Wakely  ---
That's why the bug is still open.

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2017-12-11 Thread jdbleretour at free dot fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Adrien  changed:

   What|Removed |Added

 CC||jdbleretour at free dot fr

--- Comment #5 from Adrien  ---
Still not working properly:
https://stackoverflow.com/questions/47744331/condition-variable-not-waking-up-when-used-with-a-chronodurationfloat

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2015-11-24 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Markus Trippelsdorf  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||trippels at gcc dot gnu.org
 Resolution|--- |INVALID

--- Comment #2 from Markus Trippelsdorf  ---
Build with -fsanitize=thread:

==
WARNING: ThreadSanitizer: data race (pid=15270)
  Write of size 1 at 0x00403540 by main thread:
#0 main /var/tmp/t.cc:32 (a.out+0x004016d4)

  Previous read of size 1 at 0x00403540 by thread T1 (mutexes: write M10):
Do something...
#0 void thread_loop >
>(std::chrono::duration >) /var/tmp/t.cc:17
(a.out+0x00401ad3)
Do something...
#1 void std::_Bind_simple >))(std::chrono::duration
>)>::_M_invoke<0ul>(std::_Index_tuple<0ul>)
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/functional:1430
(a.out+0x0040193e)
#2 std::_Bind_simple >))(std::chrono::duration >)>::operator()()
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/functional:1419
(a.out+0x0040193e)
Do something...
#3 std::thread::_State_impl))(std::chrono::duration >)> >::_M_run()
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/thread:186
(a.out+0x0040193e)
#4 execute_native_thread_routine  (libstdc++.so.6+0x000d082e)

  Location is global 'finish' of size 1 at 0x00403540
(a.out+0x00403540)

  Mutex M10 (0x004035a0) created at:
#0 pthread_mutex_lock  (libtsan.so.0+0x00042be0)
Do something...
#1 __gthread_mutex_lock
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/x86_64-pc-linux-gnu/bits/gthr-default.h:748
(a.out+0x004019ee)
#2 std::mutex::lock()
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/bits/mutex.h:103
(a.out+0x004019ee)
#3 std::unique_lock::lock()
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/bits/mutex.h:254
(a.out+0x004019ee)
#4 std::unique_lock::unique_lock(std::mutex&)
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/bits/mutex.h:184
(a.out+0x004019ee)
Do something...
#5 void thread_loop >
>(std::chrono::duration >) /var/tmp/t.cc:16
(a.out+0x004019ee)
#6 void std::_Bind_simple >))(std::chrono::duration
>)>::_M_invoke<0ul>(std::_Index_tuple<0ul>)
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/functional:1430
(a.out+0x0040193e)
#7 std::_Bind_simple >))(std::chrono::duration >)>::operator()()
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/functional:1419
(a.out+0x0040193e)
#8 std::thread::_State_impl))(std::chrono::duration >)> >::_M_run()
/usr/lib/gcc/x86_64-pc-linux-gnu/6.0.0/include/g++-v6/thread:186
(a.out+0x0040193e)
Do something...
#9 execute_native_thread_routine  (libstdc++.so.6+0x000d082e)

  Thread T1 (tid=15272, running) created by main thread at:
#0 pthread_create  (libtsan.so.0+0x0002bdd8)
#1 std::thread::_M_start_thread(std::unique_ptr, void (*)()) 
(libstdc++.so.6+0x000d0b34)
Do something...
#2 __libc_start_main ../csu/libc-start.c:289 (libc.so.6+0x0002062f)

SUMMARY: ThreadSanitizer: data race /var/tmp/t.cc:32 in main
==

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2015-11-24 Thread jbellon at bsc dot es
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Jorge Bellon  changed:

   What|Removed |Added

  Attachment #36824|0   |1
is obsolete||

--- Comment #3 from Jorge Bellon  ---
Created attachment 36827
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36827=edit
source file that reproduces the bug (data race fixed)

I've uploaded again the source file with the fixed data race (typo when
writting the example, sorry).

Now it passes both -fsanitize=thread and -fsanitize=address (but still does not
work as expected).

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2015-11-24 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Markus Trippelsdorf  changed:

   What|Removed |Added

 Status|RESOLVED|NEW
   Last reconfirmed||2015-11-24
 CC||redi at gcc dot gnu.org
 Resolution|INVALID |---
 Ever confirmed|0   |1

--- Comment #4 from Markus Trippelsdorf  ---
(In reply to Jorge Bellon from comment #3)
> Created attachment 36827 [details]
> source file that reproduces the bug (data race fixed)
> 
> I've uploaded again the source file with the fixed data race (typo when
> writting the example, sorry).
> 
> Now it passes both -fsanitize=thread and -fsanitize=address (but still does
> not work as expected).

OK. Thanks.

[Bug libstdc++/68519] condition_variable::wait_for does not work properly with float duration

2015-11-24 Thread jbellon at bsc dot es
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68519

Jorge Bellon  changed:

   What|Removed |Added

 CC||jbellon at bsc dot es

--- Comment #1 from Jorge Bellon  ---
Created attachment 36824
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36824=edit
source file that reproduces the bug