Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9880: boost::condition_variable.timed_wait() exception if system time < 1970
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-15 12:17:40
#9880: boost::condition_variable.timed_wait() exception if system time < 1970
-------------------------------+----------------------
Reporter: anonymous | Owner: viboes
Type: Bugs | Status: assigned
Milestone: To Be Determined | Component: thread
Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+----------------------
Comment (by alex):
I am the developer of anti-virus, respectively, our product should work
with any conditions that malicious software may do. We found that the
boost has architectural problem with the fact that he is trying to get the
system time in posix format when specifying relative time. We found some
workarounds solutions, but a problem with the condition variable could not
solve. Example executed on windows 8.1, visual studio 2012, boost_1_55_0.
Thanks!
{{{
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include "windows.h"
#include "boost/thread.hpp"
#define IF_ERR_RET(x) if(!(x)) {printf("Error: %d in %s(%d)\n",
GetLastError(), __FILE__, __LINE__); return FALSE;}
#define TRY try {
#define CATCH } catch(std::exception& exc) {printf("Exception %s in
%s(%d)\n", exc.what(), __FILE__, __LINE__);}
bool setYear(int year)
{
SYSTEMTIME tm;
GetLocalTime(&tm);
tm.wYear = year;
IF_ERR_RET(SetLocalTime(&tm));
return TRUE;
}
void Func(void)
{
Sleep(10000);
}
int _tmain(int argc, _TCHAR* argv[])
{
IF_ERR_RET(setYear(1950));
TRY;
boost::condition_variable cv;
boost::mutex mtx;
boost::mutex::scoped_lock lck(mtx);
cv.timed_wait(lck, boost::posix_time::milliseconds(1000)); //
exception
CATCH;
TRY;
boost::thread thr(&Func);
thr.timed_join(boost::posix_time::milliseconds(1000)); //
exception
CATCH;
TRY;
boost::thread thr(&Func);
thr.try_join_for(boost::chrono::milliseconds(1000)); // exception
CATCH;
TRY;
boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
// exception
CATCH;
TRY;
boost::posix_time::second_clock::local_time(); // exception
CATCH;
IF_ERR_RET(setYear(2014));
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9880#comment:6> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC