Boost C++ Libraries: Ticket #3369: posix_time::operator<< crashes with double free under possible race conditions https://svn.boost.org/trac10/ticket/3369 <p> We are using boost 1.39.0 compiled with gcc 3.4.6, and we're getting a glibc "double free or corruption" crash on this line in one of our multithreaded programs: </p> <p> mLogFile &lt;&lt; boost::posix_time::microsec_clock::local_time() (where mLogFile is of type ofstream) </p> <p> The crash behaves like a race condition, small changes to unrelated code make it disappear. </p> <p> The crash does does not happen if we use operator&lt;&lt; on to_simple_string(microsec_clock::local_time()), which is what we'll be using for now. But it would be nice if someone could take a look, maybe it's easy: </p> <p> gdb backtrace: </p> <p> <a class="missing ticket">#0</a> 0xffffe410 in <span class="underline">kernel_vsyscall () </span></p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x4029b541 in raise () from /lib/tls/libc.so.6 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x4029cdbb in abort () from /lib/tls/libc.so.6 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x402d18b5 in <span class="underline">libc_message () from /lib/tls/libc.so.6 </span></p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x402d7842 in malloc_printerr () from /lib/tls/libc.so.6 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x402d81f4 in free () from /lib/tls/libc.so.6 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x40215c61 in operator delete () from /usr/lib/libstdc++.so.6 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> 0x401f28cd in std::string::_Rep::_M_destroy () from /usr/lib/libstdc++.so.6 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> 0x401f3a78 in std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;::~basic_string() from /usr/lib/libstdc++.so.6 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9" title="#9: Bugs: config_info ambiguity error (closed: Invalid)">#9</a> 0x0807777c in boost::as_literal&lt;std::string&gt; (r=@0x40bb3190) at as_literal.hpp:109 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10" title="#10: Bugs: allyourbase.jam file is bad. (closed: Out of Date)">#10</a> 0x08076c68 in boost::algorithm::first_finder&lt;std::string&gt; (Search=@0x40bb3190) at finder.hpp:55 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/11" title="#11: Bugs: why not using mt19937? (closed: Fixed)">#11</a> 0x08075a85 in boost::algorithm::erase_all&lt;std::string, std::string&gt; (Input=@0x40bb31b0, Search=@0x40bb3190) at erase.hpp:593 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12" title="#12: Bugs: Can't specify VertexPredicate (closed: Fixed)">#12</a> 0x08072167 in boost::date_time::time_facet&lt;boost::posix_time::ptime, char, std::ostreambuf_iterator&lt;char, std::char_traits&lt;char&gt; &gt; &gt;::put (this=0x8102d28, a_next={&lt;std::iterator&lt;std::output_iterator_tag,void,void,void,void&gt;&gt; = {&lt;No data fields&gt;}, _M_sbuf = 0x80def98, _M_failed = false}, a_ios=@0x80df020, a_fill=32 ' ', a_time=@0x40bb32c8) at time_facet.hpp:325 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/13" title="#13: Bugs: iterator_adapter and abstract classes (closed: Out of Date)">#13</a> 0x08070aca in boost::posix_time::operator&lt;&lt; &lt;char, std::char_traits&lt;char&gt; &gt; (os=@0x80def94,p=@0x40bb32c8) at posix_time_io.hpp:53 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/14" title="#14: Feature Requests: Support for static data members (closed: Out of Date)">#14</a> 0x0806f392 in LoggerThread::<a class="missing wiki">WriteMessageToDisk</a> (this=0x80deed0, event_to_log={px = 0x8100328, pn = {pi_ = 0x8100080}}) at <a class="missing wiki">LoggerThread</a>.cc:116 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3369 Trac 1.4.3 Andrey Semashev Mon, 21 Sep 2009 15:06:01 GMT <link>https://svn.boost.org/trac10/ticket/3369#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3369#comment:1</guid> <description> <p> Is the streaming expression protected with a mutex lock or a similar synchronization mechanism? If not, that is the most probable source of the problem. </p> <p> If that doesn't help, a short code snippet that demonstrates the problem would be nice. </p> </description> <category>Ticket</category> </item> <item> <author>szubkov@…</author> <pubDate>Thu, 01 Oct 2009 16:13:32 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3369#comment:2 https://svn.boost.org/trac10/ticket/3369#comment:2 <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">worksforme</span> </li> </ul> <p> We haven't seen this issue reappear, so perhaps it was a temporary lapse in synchronization after all. Can be closed. </p> Ticket