Boost C++ Libraries: Ticket #8642: Global locale prevents from using Boost.Filesystem in global constructors and destructors https://svn.boost.org/trac10/ticket/8642 <p> The problem appears in particular with Boost.Log. On program termination, Boost.Log may attempt to perform final log file rotation, which involves calling Boost.Filesystem routines (path construction, in particular). But Boost.Filesystem is not usable at this point because its global locale is already destroyed. </p> <p> Boost.Filesystem should remain usable during global constructors and destructors. The global locale should either be embedded into the path object (preferred solution, IMHO) or the library should ensure its availability during these stages. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8642 Trac 1.4.3 Beman Dawes Sat, 02 Aug 2014 16:17:53 GMT status changed https://svn.boost.org/trac10/ticket/8642#comment:1 https://svn.boost.org/trac10/ticket/8642#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Beman Dawes Wed, 29 Oct 2014 13:40:53 GMT <link>https://svn.boost.org/trac10/ticket/8642#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8642#comment:2</guid> <description> <p> Andy, </p> <p> Could you please supply a simple test program that exhibits this problem? </p> <p> Even if it is fixed now, I'd like to include something in the test suite that would detect any future regression. </p> <p> Thanks, </p> <p> --Beman </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Wed, 29 Oct 2014 14:45:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8642#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8642#comment:3</guid> <description> <p> I don't have a code sample at hand; there were reports about Boost.Log (e.g. <a class="new ticket" href="https://svn.boost.org/trac10/ticket/9119" title="#9119: Bugs: memory errors and eventual segfault when using Log (new)">#9119</a>) which I debugged to this root problem. I can try and write a self-contained test later this week. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>daniel kruegler</dc:creator> <pubDate>Fri, 31 Oct 2014 22:16:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8642#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8642#comment:4</guid> <description> <p> The following example should demonstrate the problem for every currently supported platform: </p> <pre class="wiki">#include "boost/filesystem/path.hpp" namespace fs = boost::filesystem; template&lt;class&gt; struct conv_char; template&lt;&gt; struct conv_char&lt;wchar_t&gt; { typedef char value_type; static const value_type* file_name() { return "abcdefghijklmnopqrst.uvw"; } }; template&lt;&gt; struct conv_char&lt;char&gt; { typedef wchar_t value_type; static const value_type* file_name() { return L"abcdefghijklmnopqrst.uvw"; } }; typedef conv_char&lt;fs::path::value_type&gt; path_conv_char; struct A { A() { } ~A() { fs::path pa(path_conv_char::file_name()); } static A&amp; instance() { static A result; return result; } }; struct B { B() { } ~B() { A::instance(); fs::path pb(path_conv_char::file_name()); } } b; int main() { } </pre><p> The code ensures that we perform a code conversion in all cases and takes advantage of the life-cycle rules of objects with static storage duration. It gives me a seg fault using gcc and a similar crash for Visual Studio in the destructor of A. The example provokes that the locale produced by path_locale() (within path.cpp) is already destroyed when pa becomes constructed, because by path_locale() holds another function local static. </p> </description> <category>Ticket</category> </item> <item> <author>Daniel Krügler <daniel.kruegler@…></author> <pubDate>Fri, 31 Oct 2014 23:15:40 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/8642#comment:5 https://svn.boost.org/trac10/ticket/8642#comment:5 <ul> <li><strong>cc</strong> <span class="trac-author">daniel.kruegler@…</span> added </li> </ul> Ticket Andrey Semashev Tue, 04 Nov 2014 18:38:56 GMT attachment set https://svn.boost.org/trac10/ticket/8642 https://svn.boost.org/trac10/ticket/8642 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket8642.cpp</span> </li> </ul> <p> A testcase to reproduce the problem </p> Ticket Andrey Semashev Tue, 04 Nov 2014 18:39:14 GMT attachment set https://svn.boost.org/trac10/ticket/8642 https://svn.boost.org/trac10/ticket/8642 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ticket8642.valgrind.log</span> </li> </ul> <p> Valgrind log </p> Ticket Andrey Semashev Tue, 04 Nov 2014 18:40:40 GMT <link>https://svn.boost.org/trac10/ticket/8642#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8642#comment:6</guid> <description> <p> I attached a test case which works similarly to Boost.Log. I also attached a valgrind log. </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Mon, 27 Jun 2016 13:12:56 GMT</pubDate> <title>cc changed https://svn.boost.org/trac10/ticket/8642#comment:7 https://svn.boost.org/trac10/ticket/8642#comment:7 <ul> <li><strong>cc</strong> <span class="trac-author">raad@…</span> added </li> </ul> Ticket bchretien Tue, 07 Mar 2017 09:17:41 GMT <link>https://svn.boost.org/trac10/ticket/8642#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8642#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8642#comment:6" title="Comment 6">andysem</a>: </p> <blockquote class="citation"> <p> I attached a test case which works similarly to Boost.Log. I also attached a valgrind log. </p> </blockquote> <p> Note: to test the repro code from ticket8642.cpp, remember to set your locale (e.g. LANG=en_US ./ticket8642). </p> </description> <category>Ticket</category> </item> </channel> </rss>