Boost C++ Libraries: Ticket #5593: boost::interprocess::basic_string::c_str() result not null-terminated when used with shared memory allocator https://svn.boost.org/trac10/ticket/5593 <p> I'm seeing this issue using boost::interprocess:basic_string (aliases boost::container::string) allocated using boost::interprocess::allocator based on a boost::interprocess::managed_map_file::segment_manager. </p> <p> The c_str() function is not returning a null-terminated string in general. This problem does not seem to occur using boost::container::string (using the standard allocator). </p> <p> The attached test program illustrates the problem. I compiled the test under gcc 4.5 using flags -DBOOST_DATE_TIME_NO_LIB </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5593 Trac 1.4.3 Anil Gangolli <anil@…> Sat, 04 Jun 2011 21:13:45 GMT attachment set https://svn.boost.org/trac10/ticket/5593 https://svn.boost.org/trac10/ticket/5593 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> test program for ticket 5593 </p> Ticket Anil Gangolli <anil@…> Sun, 05 Jun 2011 05:46:24 GMT <link>https://svn.boost.org/trac10/ticket/5593#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5593#comment:1</guid> <description> <p> It now appears the problem is platform-specific. </p> <p> I retested on Linux (specifically Ubuntu 10.04.2) with gcc 4.4.3. I do not see the reported problem there. </p> <p> I am seeing the issue on Mac OS 10.6.7. The gcc is 4.5.3 from Mac Ports. Dynamic dependencies are: </p> <p> /opt/local/lib/gcc45/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.14.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 103.0.0) /opt/local/lib/gcc45/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10) </p> <p> I haven't yet tested on Linux with gcc 4.5.x </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 06 Jun 2011 14:10:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5593#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5593#comment:2</guid> <description> <p> I just tested on Linux (Ubuntu 10.04.2) with g++ 4.5.3 and did not see the problem there. </p> <p> So I am only able to reproduce the problem on Mac OS. Version details in my previous comment. </p> <p> The underlying cause may be a bug in one of the MacOS/MacPorts libraries or it may be due to an incorrect expectation in the Boost code that is not met on Mac OS. </p> <p> The reason that I suspect a Boost Interprocess issue is that even on the Mac platform, one sees no problem using the standard allocator, only the shared memory one. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 06 Jun 2011 21:14:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5593#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5593#comment:3</guid> <description> <p> (anil@…): </p> <p> I tested on MacOS 10.6.7 with the gcc 4.2.1 that comes with XCode and everything was fine. As a result I am retracting the bug. </p> </description> <category>Ticket</category> </item> <item> <author>anil@…</author> <pubDate>Mon, 06 Jun 2011 21:15:35 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5593#comment:4 https://svn.boost.org/trac10/ticket/5593#comment:4 <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">invalid</span> </li> </ul> Ticket dominik.ernst@… Wed, 12 Sep 2012 22:50:51 GMT <link>https://svn.boost.org/trac10/ticket/5593#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5593#comment:5</guid> <description> <p> I just found this Bug-report, when I searched for information about strange behaviour. Following Code </p> <pre class="wiki">cout &lt;&lt; model.c_str() &lt;&lt; " "; cout &lt;&lt; model &lt;&lt; std::endl; </pre><p> results in </p> <p> BS-2020Sj B�GmA BS-2020S </p> <p> (the original string is BS-2020S, model is a basic_string) which looks like a missing null-termination. </p> <p> Linux Mint 13, gcc 4.6, boost 1.47 </p> </description> <category>Ticket</category> </item> </channel> </rss>