condition_variable wait_for is broken

condition_variable wait_for is broken

Ritratto di aksenofo

tbb ver: tbb40_20111130oss

condition_variable class , method wait_for in linux broken.
wrong recalculation of time leeds to exeption generating

It take place because the result
line 403 : req.tv_nsec += static_cast( (sec - static_cast(sec))*1e9 );
may exeed 1e9 nanosec
what makes
line 421: pthread_cond_timedwait( &my_cv, lock.mutex()->native_handle(), &req ) .....
return errno 22 ( Invalid param ) and than throw an exeption

fixing patch is:

--- condition_variable 2012-01-25 09:25:13.050000085 +0300
+++ condition_variable.ORIG 2012-01-25 09:23:50.705000086 +0300
@@ -411,9 +411,6 @@
req.tv_nsec = tv.tv_usec*1000 + static_cast( (sec - static_cast(sec))*1e9 );
#endif /*(choice of OS) */

- req.tv_sec += req.tv_nsec / 1000000000;
- req.tv_nsec = req.tv_nsec % 1000000000;
-
int ec;
cv_status rc = no_timeout;
__TBB_ASSERT( lock.owns, NULL );

Good luck

2 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di Wooyoung Kim (Intel)

Thank you very much for reporting the bug.
We will incorporate the fix into the next TBB release.

Accedere per lasciare un commento.