Boost C++ Libraries: Ticket #11480: Interprocess get_last_bootup_time use of Event Log on Windows is completely unreliable https://svn.boost.org/trac10/ticket/11480 <p> We have been running into an issue where creating an interprocess message_queue would start to fail after some time on a production system (Windows 2012 Server) - throwing an interprocess_exception with error code 1 (native code=0). </p> <p> After setting up remote debugging on the production system, we tracked it down to the get_last_bootup_time() function returning false because it couldn't find the 'Event Log Started (6005)' event in the log. (win32_api.hpp) </p> <p> The Event Logs don't last forever. Windows prunes old events when the logs grow. If I understand the use of the Event Log to determine a boot time correctly, then this is a nasty hack and must be changed. It is not reliable. </p> <p> Perhaps a solution would be to maintain a 'current' boot time file. You could attempt to find the boot time using the Event log (or other technique) and write it to the 'current' file. If you couldn't obtain the boot time, just use the existing 'current' file. If no current file exists, write one with an arbitrary time (eg. 00000). At least this way, it will never fail, and usually will roll over to a new folder after a reboot. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11480 Trac 1.4.3 William J. Schilp, PhD <williamschilp@…> Wed, 16 Mar 2016 15:22:31 GMT <link>https://svn.boost.org/trac10/ticket/11480#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11480#comment:1</guid> <description> <p> i'm running into this issue on windows 8.1. even with a reboot, it appears that windows 8.1 does not log a 6005 event, so creating an interprocess message_queue never succeeds. this has never been a problem on windows 7 (we've been using this for a couple of years now and not a single windows 7 machine has run into this problem). and it appears to not be a problem on windows 10, though we've had limited testing on win10. is there any hope of a fix?? </p> </description> <category>Ticket</category> </item> <item> <author>Valentin Shtronda <valiko.ua@…></author> <pubDate>Fri, 22 Apr 2016 19:45:23 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/11480 https://svn.boost.org/trac10/ticket/11480 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">win32_api.hpp.patch</span> </li> </ul> <p> The patch with my fix/workaround to apply on top of version 1.60. Note that this fix will not compile on Windows prior to Vista or Server 2008, which do not have GetTickCount64. </p> Ticket Maksim Paramonau <mparamonau@…> Thu, 05 Jan 2017 09:05:16 GMT <link>https://svn.boost.org/trac10/ticket/11480#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11480#comment:2</guid> <description> <p> Also if an application which was run from the Guest account tries to open queries created by an application from a regular user, the queries will be renamed so far as the guest user doesn't have enough right to access to the Windows Event log. From the guest account the function 'get_last_bootup_time' returns 'true' even if the function 'OpenEventLogA' returns NULL! (I believe it's an error, it should return false and in this case the boost library throws an exception). Further in the function 'create_shared_dir_and_clean_old' the boost library tries to erase all old directories created in the previous boot sessions (boost calls the function 'unlink' to emulate UNIX unlink semantics in windows). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Sun, 12 Feb 2017 20:44:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11480#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11480#comment:3</guid> <description> <p> A new experimental option for windows, activated with macro BOOST_INTERPROCESS_BOOTSTAMP_IS_SESSION_MANAGER_BASED was recently added with commit: </p> <p> <a class="ext-link" href="https://github.com/boostorg/interprocess/commit/eedc9b0a4efd428104c5c9ebb61c83704166448e"><span class="icon">​</span>https://github.com/boostorg/interprocess/commit/eedc9b0a4efd428104c5c9ebb61c83704166448e</a> </p> <p> It only works with Vista and newer systems. If this solution is more stable than previous ones, it will become the default choice. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 24 Apr 2017 15:54:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11480#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11480#comment:4</guid> <description> <p> Have you considered using WMI? </p> <p> The Win32_OperatingSystem class has a <a class="missing wiki">LastBootUpTime</a> property. </p> <p> <a class="ext-link" href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa394239(v=vs.85).aspx"><span class="icon">​</span>https://msdn.microsoft.com/en-us/library/windows/desktop/aa394239(v=vs.85).aspx</a> </p> <p> As described in the second answer here: <a class="ext-link" href="http://stackoverflow.com/questions/10853985/programmatically-getting-system-boot-up-time-in-c-windows"><span class="icon">​</span>http://stackoverflow.com/questions/10853985/programmatically-getting-system-boot-up-time-in-c-windows</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 27 Apr 2017 15:48:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11480#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11480#comment:5</guid> <description> <p> WMI was one of the older approaches and it was not reliable with hibernation and time changes. </p> </description> <category>Ticket</category> </item> </channel> </rss>