Boost C++ Libraries: Ticket #4010: Boost message queue bug https://svn.boost.org/trac10/ticket/4010 <blockquote> <p> There is a serious bug within the message queue. Originally boost message queue intends to create temp files under a randomly generated temp folder, boost uses undocumented Windows APIs to get the bootstamp to generate the folder name, the folder name looks like "C:\Documents and Settings\All Users\Application Data/boost_interprocess/D0F325BE8579CA01/". Unfortunately that there is a bug of the method to generate the bootstamp, that the bootstamp will vary, even without rebooting!! </p> </blockquote> <p> </p> <blockquote> <p> This will cause problems that, if a message queue is running for hours, further request from client cannot connect to it because of the newly generated bootstamp is different!! </p> </blockquote> <p> </p> <blockquote> <p> This bug can be replicated by </p> </blockquote> <p> [Method 1] </p> <ol><li>Write a test program (A), create a message queue and let it running for hours (e.g. 3hours...) When the message queue is created, a folder under "C:\Documents and Settings\All Users\Application Data\boost_interprocess\D0F325BE8579CA01" will be created. Notice the folder name "D0F325BE8579CA01". </li><li>Write another test program (B) to connect to the message queue created by test program (A). You will notice that it's unable to connect to the message queue created by program (A). </li></ol><p> </p> <blockquote> <blockquote> <p> You can also find that another folder "C:\Documents and Settings\All Users\Application Data\boost_interprocess\9053E2F2EBC0CA01" is created. Notice that the folder name "9053E2F2EBC0CA01" is different from "D0F325BE8579CA01". </p> </blockquote> </blockquote> <p> [Method 2] </p> <blockquote> <p> There is another more simple method to replicate the issue instead of to wait for hours. The steps are mostly the same as [Method 1], the difference is before running test program (B), please change the system time. </p> </blockquote> <p> </p> <blockquote> <p> Afterwards test program (B) is unable to connect to test program (A) anymore. </p> </blockquote> <p> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4010 Trac 1.4.3 rusty0831 <rusty_lai@…> Mon, 15 Mar 2010 06:06:01 GMT <link>https://svn.boost.org/trac10/ticket/4010#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:1</guid> <description> <p> *Note: What I mean is the "boost::interprocess::message_queue" class. </p> </description> <category>Ticket</category> </item> <item> <author>Anders Widén <anders.widen@…></author> <pubDate>Thu, 15 Apr 2010 10:08:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4010#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:2</guid> <description> <p> This is even more serious! The problem seems to apply to <span class="underline">all</span> named Boost.Interprocess resources (e.g. shared memory and named semaphores). </p> <p> As a workaround I have rebuilt my code without the pre-processor symbols BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME and BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME. I believe this would give me filesystem-persistence but this should be ok since the documentation is stating that all named resources could have either filesystem or kernel persistence. </p> </description> <category>Ticket</category> </item> <item> <author>Anders Widén <anders.widen@…></author> <pubDate>Thu, 15 Apr 2010 10:09:44 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/4010#comment:3 https://svn.boost.org/trac10/ticket/4010#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">anders.widen@…</span> added </li> </ul> Ticket anonymous Thu, 06 May 2010 04:27:25 GMT <link>https://svn.boost.org/trac10/ticket/4010#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:4</guid> <description> <p> Thanks for this bug, it saves us a lot of time to trace a bug: when the applications are running for a few hrs, they won't communicate correctly with each other if the child process is created dynamically. </p> <p> I have a simple fix for this, only works for windows system. Try to use the windows_shared_memory instead of shared_memory_object. It works as changing the system time, not test on leave it there for a few hrs. If anyone interested in the changes: replace detail::managed_open_or_create_impl&lt; windows_shared_memory, false&gt; m_shmem; with detail::managed_open_or_create_impl&lt;shared_memory_object&gt; m_shmem; and change the header include. comment out the message_queue::remove. </p> <p> Hope this could help some1 on Windows to work around this problem by now. </p> </description> <category>Ticket</category> </item> <item> <author>dxj19831029@…</author> <pubDate>Thu, 06 May 2010 04:29:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4010#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:5</guid> <description> <p> Thanks for this bug, it saves us a lot of time to trace a bug: when the applications are running for a few hrs, they won't communicate correctly with each other if the child process is created dynamically. </p> <p> I have a simple fix for this, only works for windows system. Try to use the windows_shared_memory instead of shared_memory_object. It works as changing the system time, not test on leave it there for a few hrs. If anyone interested in the changes: replace detail::managed_open_or_create_impl&lt; windows_shared_memory, false&gt; m_shmem; with detail::managed_open_or_create_impl&lt;shared_memory_object&gt; m_shmem; and change the header include. comment out the message_queue::remove. </p> <p> Hope this could help some1 on Windows to work around this problem by now. </p> </description> <category>Ticket</category> </item> <item> <author>klaas@…</author> <pubDate>Tue, 27 Jul 2010 11:42:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4010#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:6</guid> <description> <p> I also noted this bug. It happened when using a shared_memory_object. We have a windows service that keeps running that we communicate with. After a while we had clients that failed to communicate with it. </p> <p> I tracked down the bug. It seems that <a class="missing wiki">NtQuerySystemInformation</a> is used in get_system_time_of_day_information to create the path to store the files for sharing the memory. I noticed that after windows changed the time/date either by the Windows Time synchronization or by doing it manually, <a class="missing wiki">NtQuerySystemInformation</a> returned another boot time then before. Because of this, when another process was started and tried to communicate with the windows service it failed as it was looking for the files in a different directory. </p> <p> I don't really have a suggestion with a decent fix. A workaround could be disabling the Windows Time service that does automatic synchronization (this workaround is untested). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Tue, 27 Jul 2010 12:21:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4010#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:7</guid> <description> <p> Try latest trunk code. <a class="missing wiki">NtQuerySystemInformation</a> has been replaced with a call to WMI (slower, but I think it's much more robust). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 26 Aug 2010 10:20:26 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/4010#comment:8 https://svn.boost.org/trac10/ticket/4010#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">new</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">Boost 1.43.0</span> → <span class="trac-field-new">Boost-1.45.0</span> </li> </ul> <p> Fixed for Boost 1.45 in release branch </p> Ticket marek Wed, 17 Nov 2010 10:16:52 GMT <link>https://svn.boost.org/trac10/ticket/4010#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:9</guid> <description> <p> i have been hit by this bug for longer also and always use workaround </p> <p> testing beta 1.45 release now </p> <p> seems now it is working on my vista(32bit) OS. but it still fails on legacy XP (32bit) i don't know about others versions </p> <p> so i back to use my work-around of this problem and it is working smoothly again </p> <p> \boost\boost\interprocess\detail\tmp_dir_helpers.hpp </p> <pre class="wiki">#if defined (BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME) inline void get_bootstamp(std::string &amp;s, bool add = false) { std::string bootstamp; winapi::get_last_bootup_time(bootstamp); + bootstamp = ""; if(add){ s += bootstamp; } else{ s = bootstamp; } } #elif defined(BOOST_INTERPROCESS_HAS_BSD_KERNEL_BOOTTIME) </pre><p> if any1 else is seeing this it may be worth reopening this bug </p> <p> thanks </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Wed, 17 Nov 2010 20:09:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4010#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4010#comment:10</guid> <description> <p> I took a look at the WMI code and noticed that in a few places you pass wide strings to COM methods. Strictly speaking, this is not correct because COM methods accept BSTRs, which are binary incompatible with wide C strings, unless the method implementation treats them as wide C strings. In particular, if it calls <a class="missing wiki">SysStringLen</a> on the argument, the result will be undefined. </p> <p> FWIW, from <a class="ext-link" href="http://article.gmane.org/gmane.comp.lib.boost.devel/208308"><span class="icon">​</span>this thread</a> it seems that using WMI has its drawbacks, let alone the complexity. Perhaps, using performance counters would suffice? <a class="ext-link" href="http://www.osronline.com/showThread.cfm?link=10513"><span class="icon">​</span>Here</a> I found an example of reading a few system counters, of which "\Process(System)\Elapsed Time" might be what you need. The registry key also looks interesting but I didn't find a way to interpret it (looks like it changed its format in Vista). I did not dig deep enough into the code though, so this may be of little help to you. </p> </description> <category>Ticket</category> </item> </channel> </rss>