Opened 7 years ago

Last modified 5 years ago

#11480 new Bugs

Interprocess get_last_bootup_time use of Event Log on Windows is completely unreliable

Reported by: Craig White <cwhite102@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.57.0 Severity: Showstopper
Keywords: message_queue bootup Cc:

Description

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).

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)

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.

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.

Attachments (1)

win32_api.hpp.patch (2.3 KB ) - added by Valentin Shtronda <valiko.ua@…> 6 years ago.
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.

Download all attachments as: .zip

Change History (6)

comment:1 by William J. Schilp, PhD <williamschilp@…>, 7 years ago

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??

by Valentin Shtronda <valiko.ua@…>, 6 years ago

Attachment: win32_api.hpp.patch added

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.

comment:2 by Maksim Paramonau <mparamonau@…>, 6 years ago

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).

comment:3 by Ion Gaztañaga, 6 years ago

A new experimental option for windows, activated with macro BOOST_INTERPROCESS_BOOTSTAMP_IS_SESSION_MANAGER_BASED was recently added with commit:

https://github.com/boostorg/interprocess/commit/eedc9b0a4efd428104c5c9ebb61c83704166448e

It only works with Vista and newer systems. If this solution is more stable than previous ones, it will become the default choice.

comment:5 by Ion Gaztañaga, 5 years ago

WMI was one of the older approaches and it was not reliable with hibernation and time changes.

Note: See TracTickets for help on using tickets.