Boost C++ Libraries: Ticket #11368: boost thread's usage of CreateWaitableTimer wakes PC from sleep (doh) https://svn.boost.org/trac10/ticket/11368 <p> Hi, </p> <p> after upgrading to boost 1.58 from 1.57 a lot of users complained that my app was prematurely aborting the PC's sleep state. The culprit can easily detected and it was indeed my process: "powercfg /lastwake" </p> <p> It shows that the process had set a "wake timer". The changes in boost/libs/thread/src/win32/thread.cpp seem to be the cause. </p> <p> Please remove usage of "<a class="missing wiki">CreateWaitableTimer</a>" in function "interruptible_wait()" or at least provide some means (preprocessor variable, whatever) to allow compilation of boost::thread without "<a class="missing wiki">CreateWaitableTimer</a>". </p> <p> Thanks </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11368 Trac 1.4.3 anonymous Mon, 01 Jun 2015 19:44:27 GMT <link>https://svn.boost.org/trac10/ticket/11368#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:1</guid> <description> <p> Test system: Windows 7 x64 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 01 Jun 2015 19:49:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:2</guid> <description> <p> <a class="missing wiki">CreateWaitableTimer</a> is used by two functions in boost/libs/thread/src/win32/thread.cpp: </p> <pre class="wiki">bool interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time) bool non_interruptible_wait(detail::win32::handle handle_to_wait_for,detail::timeout target_time) </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 02 Jun 2015 08:09:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:3</guid> <description> <p> The problem isn't the use of waitable timers per se, but the use of <code>SetWaitableTimerEx</code>, which always wakes the system from sleep if possible. Boost.Thread should revert to using plain <code>SetWaitableTimer</code>, ensuring that <code>false</code> is passed for the <code>bResume</code> parameter so that the timer doesn't wake the system. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 02 Jun 2015 15:23:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:4</guid> <description> <blockquote class="citation"> <p> but the use of <a class="missing wiki">SetWaitableTimerEx</a> </p> </blockquote> <p> You're right! I have reverted thread.cpp from version 1.58 to 1.57 and my users have confirmed that the unexpected wake up problem is solved! So this is indeed a boost regression after 1.57. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 28 Jun 2015 09:08:52 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/11368#comment:5 https://svn.boost.org/trac10/ticket/11368#comment:5 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">Niall Douglas</span> </li> </ul> <p> Niall, please could you take a look. </p> Ticket Niall Douglas Sun, 28 Jun 2015 13:22:57 GMT <link>https://svn.boost.org/trac10/ticket/11368#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11368#comment:3" title="Comment 3">anonymous</a>: </p> <blockquote class="citation"> <p> The problem isn't the use of waitable timers per se, but the use of <code>SetWaitableTimerEx</code>, which always wakes the system from sleep if possible. Boost.Thread should revert to using plain <code>SetWaitableTimer</code>, ensuring that <code>false</code> is passed for the <code>bResume</code> parameter so that the timer doesn't wake the system. </p> </blockquote> <p> <a class="ext-link" href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/8047b845-2a1b-4220-a4b7-b10234bce924/unable-to-resume-in-windows-7-through-set-waitable-timer?forum=vcgeneral"><span class="icon">​</span>https://social.msdn.microsoft.com/Forums/vstudio/en-US/8047b845-2a1b-4220-a4b7-b10234bce924/unable-to-resume-in-windows-7-through-set-waitable-timer?forum=vcgeneral</a> claimed that resumption of power from <a class="missing wiki">SetWaitableTimerEx</a> didn't work. I therefore made the untested assumption that the WAKE_CONTEXT I passed didn't wake the machine. </p> <p> I'll test that over here and see what I can figure out. The Microsoft documentation on WAKE_CONTEXT approaches nil unfortunately. </p> <p> Niall </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Mon, 10 Aug 2015 06:33:41 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/11368#comment:7 https://svn.boost.org/trac10/ticket/11368#comment:7 <ul> <li><strong>cc</strong> <span class="trac-author">raad@…</span> added </li> </ul> Ticket Niall Douglas Tue, 11 Aug 2015 16:49:37 GMT <link>https://svn.boost.org/trac10/ticket/11368#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11368#comment:6" title="Comment 6">ned14</a>: </p> <blockquote class="citation"> <p> I'll test that over here and see what I can figure out. The Microsoft documentation on WAKE_CONTEXT approaches nil unfortunately. </p> </blockquote> <p> I'll be honest: until the AFIO review and then <a class="missing wiki">CppCon</a> is over, I won't have the time to investigate this. Anyone else willing to take it on is welcome. </p> <p> Niall </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 17 Sep 2015 17:48:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:9</guid> <description> <p> We have the same issue with 1.58. Any updates on a fix for this? </p> <p> Thanks! </p> <p> Markus </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 17 Sep 2015 17:57:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:10</guid> <description> <p> Hi, I believe that we will need to wait until Niall has some time to look at this. I'm unable to test on Windows and don't the Windows interface well. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Niall Douglas</dc:creator> <pubDate>Fri, 18 Sep 2015 12:48:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:11</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11368#comment:10" title="Comment 10">viboes</a>: </p> <blockquote class="citation"> <p> Hi, I believe that we will need to wait until Niall has some time to look at this. I'm unable to test on Windows and don't the Windows interface well. </p> </blockquote> <p> I gave it a quick test on my Win8.1 machine here and found no wakes from sleep. I'd suggest it's something in the system settings maybe. I didn't have much time though, it was only a very quick test. </p> <p> I'd suggest reverting the patch I committed. I am no longer employed by the client who wanted that patch, so I have no objections for it returning to the previous code as that is less hassle for everybody. </p> <p> Niall </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 18 Sep 2015 21:35:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:12</guid> <description> <p> Niall please, be free to do it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Niall Douglas</dc:creator> <pubDate>Fri, 18 Sep 2015 22:15:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:13</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11368#comment:12" title="Comment 12">viboes</a>: </p> <blockquote class="citation"> <p> Niall please, be free to do it. </p> </blockquote> <p> I'm on vacation from Boost library development until January. Had enough of Boost for a while. </p> <p> But if someone else raises a pull request on github reverting the commit, I will check it and approve it. </p> <p> Niall </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Mikael Olenfalk</dc:creator> <pubDate>Wed, 23 Sep 2015 12:57:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:14</guid> <description> <p> This pull request fixes the issue, passing null as REASON_CONTEXT is not document but works according to tests we made. </p> <p> <a class="ext-link" href="https://github.com/boostorg/thread/pull/67"><span class="icon">​</span>https://github.com/boostorg/thread/pull/67</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 23 Sep 2015 17:25:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:15</guid> <description> <p> Niall, what do you think of the patch? What others think? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 27 Sep 2015 13:45:03 GMT</pubDate> <title>owner, status, milestone changed https://svn.boost.org/trac10/ticket/11368#comment:16 https://svn.boost.org/trac10/ticket/11368#comment:16 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Niall Douglas</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>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/9ac736a4c4214cdb01caaa84a1121b3846dc87b4"><span class="icon">​</span>https://github.com/boostorg/thread/commit/9ac736a4c4214cdb01caaa84a1121b3846dc87b4</a> </p> Ticket viboes Wed, 21 Oct 2015 22:19:27 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11368#comment:17 https://svn.boost.org/trac10/ticket/11368#comment:17 <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> </ul> Ticket anonymous Wed, 16 Mar 2016 05:11:23 GMT <link>https://svn.boost.org/trac10/ticket/11368#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:18</guid> <description> <p> what version is the issue fixed in ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 22 Jun 2016 00:21:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:19 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:19</guid> <description> <p> Who can tell which version has the fix? is it 1.61.0? </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Wed, 22 Jun 2016 07:02:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11368#comment:20 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11368#comment:20</guid> <description> <p> The fix is in 1.60, as you can tell from the tag of the commit on github. </p> </description> <category>Ticket</category> </item> </channel> </rss>