Boost C++ Libraries: Ticket #9880: [windows] boost::condition_variable.timed_wait() exception if system time < 1970 https://svn.boost.org/trac10/ticket/9880 <p> Os: any windows. Set system time &lt; 01.01.1970, for example 01.01.1950. </p> <p> Any call to boost::condition_variable.timed_wait() with relative(!) time throw exception because boost try get system time in posix format. </p> <p> How to fix: boost\thread\win32\thread_data.hpp, line 179 (boost 1.55.0). In constructor </p> <pre class="wiki"> timeout(uintmax_t milliseconds_): start(win32::GetTickCount64()), milliseconds(milliseconds_), relative(true), abs_time(boost::get_system_time()) {} </pre><p> we set "relative(true)" and there for not need to set variable "abs_time". Must be: </p> <pre class="wiki"> timeout(uintmax_t milliseconds_): start(win32::GetTickCount64()), milliseconds(milliseconds_), relative(true) {} </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9880 Trac 1.4.3 anonymous Mon, 14 Apr 2014 11:24:12 GMT component changed; owner set https://svn.boost.org/trac10/ticket/9880#comment:1 https://svn.boost.org/trac10/ticket/9880#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">az_sw_dude</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">date_time</span> </li> </ul> Ticket viboes Mon, 14 Apr 2014 17:11:43 GMT owner, status, component changed https://svn.boost.org/trac10/ticket/9880#comment:2 https://svn.boost.org/trac10/ticket/9880#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">az_sw_dude</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">date_time</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Mon, 14 Apr 2014 17:13:07 GMT description changed https://svn.boost.org/trac10/ticket/9880#comment:3 https://svn.boost.org/trac10/ticket/9880#comment:3 <ul> <li><strong>description</strong> modified (<a href="/trac10/ticket/9880?action=diff&amp;version=3">diff</a>) </li> </ul> Ticket viboes Mon, 14 Apr 2014 17:17:17 GMT <link>https://svn.boost.org/trac10/ticket/9880#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:4</guid> <description> <p> This code has been there since the beginning. </p> <p> Have you found a regression? If yes, on which version it was working? </p> <p> Could you provide an example, please? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 14 Apr 2014 17:18:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9880#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:5</guid> <description> <p> BTW, why do you want to set the current time &lt; 1970? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>alex</dc:creator> <pubDate>Tue, 15 Apr 2014 12:17:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9880#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:6</guid> <description> <p> 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! </p> <pre class="wiki">#include "targetver.h" #include &lt;stdio.h&gt; #include &lt;tchar.h&gt; #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&amp; exc) {printf("Exception %s in %s(%d)\n", exc.what(), __FILE__, __LINE__);} bool setYear(int year) { SYSTEMTIME tm; GetLocalTime(&amp;tm); tm.wYear = year; IF_ERR_RET(SetLocalTime(&amp;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(&amp;Func); thr.timed_join(boost::posix_time::milliseconds(1000)); // exception CATCH; TRY; boost::thread thr(&amp;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; } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 15 Apr 2014 16:56:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9880#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:7</guid> <description> <p> Ok, I understand your concern. I will take a look. Could you answer to the questions: Have you found a regression? If yes, on which version it was working? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>alex</dc:creator> <pubDate>Wed, 16 Apr 2014 07:50:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9880#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:8</guid> <description> <p> I was not looking for a regression, but I think that this error has always been. boost_1_51_0, boost_1_55_0 - the problem persists. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 19 Apr 2014 11:00:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9880#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:9</guid> <description> <p> I have no access to a windows machine. So before updating the code I want to be sure it fixes the issue. </p> <p> Please, could you point me where abs_time is used if relative is true? </p> <p> Thanks in advance, Vicente </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 19 Apr 2014 11:10:18 GMT</pubDate> <title>summary changed https://svn.boost.org/trac10/ticket/9880#comment:10 https://svn.boost.org/trac10/ticket/9880#comment:10 <ul> <li><strong>summary</strong> <span class="trac-field-old">boost::condition_variable.timed_wait() exception if system time &lt; 1970</span> → <span class="trac-field-new">[windows] boost::condition_variable.timed_wait() exception if system time &lt; 1970</span> </li> </ul> Ticket viboes Sun, 14 Sep 2014 18:25:34 GMT <link>https://svn.boost.org/trac10/ticket/9880#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:11</guid> <description> <p> Could you tell me which exception is thrown? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 16 Sep 2014 06:26:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9880#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9880#comment:12</guid> <description> <p> I have removed the initialization </p> <pre class="wiki">abs_time(boost::get_system_time()) </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 23 Sep 2014 00:13:11 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/9880#comment:13 https://svn.boost.org/trac10/ticket/9880#comment:13 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> Ticket