Boost C++ Libraries: Ticket #5928: FileSystem runtime error: locale::facet::_S_create_c_locale name not valid https://svn.boost.org/trac10/ticket/5928 <p> I know this has been claimed to be fixed in v1.47. I thought so. Unfortunately, this is true only in SOME systems I believe. My application was compiled with: </p> <p> -pedantic -static -m64 -O3 </p> <p> The binary works in many machines but the one I got problem with. It even runs a portion of the program but then throws the exception as shown in the title. </p> <p> The machine in trouble got: </p> <p> Linux xxx.xxx.xxx 2.6.18-164.6.1.el5 <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> SMP Tue Nov 3 16:12:36 EST 2009 x86_64 x86_64 x86_64 GNU/Linux </p> <p> the output of g++ --version: g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46) </p> <p> Please take a look at this because it stops my binary from proceeding. THANK YOU SO MUCH Beman! </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5928 Trac 1.4.3 midnight-runner@… Fri, 21 Oct 2011 14:07:23 GMT <link>https://svn.boost.org/trac10/ticket/5928#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:1</guid> <description> <p> I can confirm this, even though the problem is kind of strange ... </p> <p> I'm using boost 1.47 and gcc 4.6.1 and doing static compilation as well. To run the program, I send the comandline (with parameters) to a cluster running the (sun) grid engine. Hence, I'm not in an interactive shell. If LC_ALL isn't set to 'C' in this shell (export LC_ALL=C) I will end up with "Error: locale::facet::_S_create_c_locale name not valid." However, if I log in to the maschine and execute the program without(!) setting LC_ALL to 'C', I can execute the program without problems. </p> <p> Here's the system: Linux PC_NAME 2.6.38-10-server <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/46" title="#46: Tasks: Perforce Jam 2.4 integration (closed: None)">#46</a>~lucid1-Ubuntu SMP Wed Jul 6 20:19:32 UTC 2011 x86_64 GNU/Linux </p> </description> <category>Ticket</category> </item> <item> <author>midnight-runner@…</author> <pubDate>Fri, 21 Oct 2011 14:26:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:2</guid> <description> <p> Update: Oh I just realized i used the wrong machine to do the interactive test ... and now it turns out that the programs fails in the interactive sessions as well, as long LC_ALL isn't set to 'C'. </p> <p> System: Linux mphy-s01 2.6.31-21-generic <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/59" title="#59: Tasks: Source-&amp;gt;Target Expansion Process (closed: Fixed)">#59</a>-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Sun, 22 Jan 2012 16:00:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5928#comment:2" title="Comment 2">midnight-runner@…</a>: </p> <blockquote class="citation"> <p> Update: Oh I just realized i used the wrong machine to do the interactive test ... and now it turns out that the programs fails in the interactive sessions as well, as long LC_ALL isn't set to 'C'. </p> <p> System: Linux mphy-s01 2.6.31-21-generic <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/59" title="#59: Tasks: Source-&amp;gt;Target Expansion Process (closed: Fixed)">#59</a>-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux </p> </blockquote> <p> I'm going to need a little test program that demonstrates this problem. My tests here all work perfectly, running fine if the environment is valid, otherwise throwing an exception after main() has started. So it would be very helpful to see your code that is failing, and be able to test with it here. </p> <p> Thanks, </p> <p> --Beman </p> </description> <category>Ticket</category> </item> <item> <author>midnight-runner@…</author> <pubDate>Wed, 25 Jan 2012 14:33:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5928#comment:3" title="Comment 3">bemandawes</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5928#comment:2" title="Comment 2">midnight-runner@…</a>: </p> <blockquote class="citation"> <p> Update: Oh I just realized i used the wrong machine to do the interactive test ... and now it turns out that the programs fails in the interactive sessions as well, as long LC_ALL isn't set to 'C'. </p> <p> System: Linux mphy-s01 2.6.31-21-generic <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/59" title="#59: Tasks: Source-&amp;gt;Target Expansion Process (closed: Fixed)">#59</a>-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux </p> </blockquote> <p> I'm going to need a little test program that demonstrates this problem. My tests here all work perfectly, running fine if the environment is valid, otherwise throwing an exception after main() has started. So it would be very helpful to see your code that is failing, and be able to test with it here. </p> <p> Thanks, </p> <p> --Beman </p> </blockquote> <p> Ok I have prepared a few test cases with two different systems (different compilers). First of all, the problem occurs only if the programs are linked statically and only if codesample 1 is used. Codesample 2 works fine. </p> <p> System 1 (Ubuntu 11.10): Linux XXX 3.0.0-15-server <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/25" title="#25: Bugs: duplicate symbol string_compare on Sun (closed: Fixed)">#25</a>-Ubuntu SMP Mon Jan 2 19:14:55 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux gcc version 4.6.1 (<a class="missing wiki">Ubuntu/Linaro</a> 4.6.1-9ubuntu3) </p> <p> System 2 (Ubuntu 09.10): Linux XXX 2.6.31-21-generic <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/59" title="#59: Tasks: Source-&amp;gt;Target Expansion Process (closed: Fixed)">#59</a>-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) </p> <p> Boost with version 1.48 was employed and both systems use the same boost includes and libs (via nfs shares). </p> <p> Codesample 1 (won't work if compiled statically with system 1 and running on system 2 with "incorrec LC-ALL"): </p> <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; int main ( int argc, char *argv[] ) { boost::filesystem::path path; std::string filename("readme.txt"); path = filename; // this isn't working // path = "readme.txt"; // this isn't working std::cout &lt;&lt; "OK" &lt;&lt; std::endl; return 0; } </pre><p> Codesample 2 (works all the time): </p> <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; int main ( int argc, char *argv[] ) { boost::filesystem::path path("readme.txt"); std::cout &lt;&lt; "OK" &lt;&lt; std::endl; return 0; } </pre><p> Compiling codesample 1 with system 1:<br /> g++ main.cpp -o test_SYS-1_dyn -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH<br /> g++ main.cpp -o test_SYS-1_sta -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH -static </p> <p> Compiling codesample 1 with system 2:<br /> g++ main.cpp -o test_SYS-2_dyn -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH<br /> g++ main.cpp -o test_SYS-2_sta -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH -static </p> <p> Running the programs: </p> <p> With system 1: <br /> and export LC-ALL='C': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta:OK <br /> test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> and export LC-ALL='en_GB.UTF-8': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta:OK <br /> test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> With system 2: <br /> and export LC-ALL='C': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta:OK <br /> test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> and export LC-ALL='en_GB.UTF-8': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta: terminate called after throwing an instance of 'std::runtime_error' </p> <blockquote> <p> what(): locale::facet::_S_create_c_locale name not valid </p> </blockquote> <p> Aborted test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> Thanks, </p> <p> Christian </p> </description> <category>Ticket</category> </item> <item> <author>Nickolay Cherney <koliasvskj@…></author> <pubDate>Mon, 06 Feb 2012 07:06:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5928#comment:4" title="Comment 4">midnight-runner@…</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5928#comment:3" title="Comment 3">bemandawes</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5928#comment:2" title="Comment 2">midnight-runner@…</a>: </p> <blockquote class="citation"> <p> Update: Oh I just realized i used the wrong machine to do the interactive test ... and now it turns out that the programs fails in the interactive sessions as well, as long LC_ALL isn't set to 'C'. </p> <p> System: Linux mphy-s01 2.6.31-21-generic <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/59" title="#59: Tasks: Source-&amp;gt;Target Expansion Process (closed: Fixed)">#59</a>-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux </p> </blockquote> <p> I'm going to need a little test program that demonstrates this problem. My tests here all work perfectly, running fine if the environment is valid, otherwise throwing an exception after main() has started. So it would be very helpful to see your code that is failing, and be able to test with it here. </p> <p> Thanks, </p> <p> --Beman </p> </blockquote> <p> Ok I have prepared a few test cases with two different systems (different compilers). First of all, the problem occurs only if the programs are linked statically and only if codesample 1 is used. Codesample 2 works fine. </p> <p> System 1 (Ubuntu 11.10): Linux XXX 3.0.0-15-server <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/25" title="#25: Bugs: duplicate symbol string_compare on Sun (closed: Fixed)">#25</a>-Ubuntu SMP Mon Jan 2 19:14:55 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux gcc version 4.6.1 (<a class="missing wiki">Ubuntu/Linaro</a> 4.6.1-9ubuntu3) </p> <p> System 2 (Ubuntu 09.10): Linux XXX 2.6.31-21-generic <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/59" title="#59: Tasks: Source-&amp;gt;Target Expansion Process (closed: Fixed)">#59</a>-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) </p> <p> Boost with version 1.48 was employed and both systems use the same boost includes and libs (via nfs shares). </p> <p> Codesample 1 (won't work if compiled statically with system 1 and running on system 2 with "incorrec LC-ALL"): </p> <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; int main ( int argc, char *argv[] ) { boost::filesystem::path path; std::string filename("readme.txt"); path = filename; // this isn't working // path = "readme.txt"; // this isn't working std::cout &lt;&lt; "OK" &lt;&lt; std::endl; return 0; } </pre><p> Codesample 2 (works all the time): </p> <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; int main ( int argc, char *argv[] ) { boost::filesystem::path path("readme.txt"); std::cout &lt;&lt; "OK" &lt;&lt; std::endl; return 0; } </pre><p> Compiling codesample 1 with system 1:<br /> g++ main.cpp -o test_SYS-1_dyn -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH<br /> g++ main.cpp -o test_SYS-1_sta -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH -static </p> <p> Compiling codesample 1 with system 2:<br /> g++ main.cpp -o test_SYS-2_dyn -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH<br /> g++ main.cpp -o test_SYS-2_sta -L$LIB_PATH -lboost_system -lboost_filesystem -I$INCLUDE_PATH -static </p> <p> Running the programs: </p> <p> With system 1: <br /> and export LC-ALL='C': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta:OK <br /> test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> and export LC-ALL='en_GB.UTF-8': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta:OK <br /> test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> With system 2: <br /> and export LC-ALL='C': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta:OK <br /> test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> and export LC-ALL='en_GB.UTF-8': <br /> test_SYS-1_dyn:OK <br /> test_SYS-1_sta: terminate called after throwing an instance of 'std::runtime_error' </p> <blockquote> <p> what(): locale::facet::_S_create_c_locale name not valid </p> </blockquote> <p> Aborted test_SYS-2_dyn:OK <br /> test_SYS-2_sta:OK <br /> </p> <p> Thanks, </p> <p> Christian </p> </blockquote> <p> I experienced similar problem when I linked statically to boost and runtime libraries; but the reason was not a Boost. </p> <p> AFAIK the line <br /> <code>path = filename; // this isn't working</code> <br /> internally calls to some STL's functions. One of them eventually calls to codecvt() constructor which in turn calls to the <code>newlocale(...)</code> function from glibc and throws the <code>locale::facet::_S_create_c_locale</code> exception if newlocale() fails (i.e. returns 0). </p> <p> The system where I built the application is Slackware 13.37 (like System 1 in your case) with glibc-2.13. But the system where the application was intended to run is Slackware 12.0 (System 2) with glibc-2.7 </p> <p> Trying to strace the application on System 2 shows that (as a result of a call to newlocale()) statically linked glibc-2.13 opens /usr/lib/locale/ru_RU.koi8r/LC_CTYPE file (I guess it would be /usr/lib/locale/en_GB.utf8/LC_CTYPE in your testcase) it stumbles upon incompatible version of this file (from glibc-2.7). </p> <p> Exact file which is opened by call to glibc's newlocale() depends on LC_ALL (or LANG if no LC_ALL set) environment variable; but if LC_ALL/LANG is set to standard intrinsic locale (e.g. LC_ALL=C or LC_ALL=POSIX) then glibc-2.13 constructs the locale without opening any file, so the newlocale() call is successful in this case. If one manages to link application to runtime libraries dynamically (regretfully this is not my case) then the call to newlocale() would be successful too. </p> <p> Hope this helps. Good luck. </p> </description> <category>Ticket</category> </item> <item> <author>hugh.m.bright@…</author> <pubDate>Sat, 07 Jul 2012 23:51:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:6</guid> <description> <p> I can reproduce this as well, the only difference beteween my "works" machine and "doesnt works" machine is the version of libstdc++ involved. </p> <p> Following <a class="ext-link" href="http://stackoverflow.com/questions/10354636/how-do-you-find-what-version-of-libstdc-library-is-installed-on-your-linux-mac"><span class="icon">​</span>http://stackoverflow.com/questions/10354636/how-do-you-find-what-version-of-libstdc-library-is-installed-on-your-linux-mac</a> </p> <p> strings /usr/lib/libstdc++.so.6 | grep GLIBCXX </p> <p> Machine that doesn't work: list stops with GLIBCXX_3.4.13 Machine that does work: list stops with GLIBCXX_3.4.16 </p> <p> Test program to demonstrate crash: </p> <p> #include &lt;boost/filesystem.hpp&gt; main() { boost::filesystem::path fp = boost::filesystem::current_path(); } </p> </description> <category>Ticket</category> </item> <item> <author>koliasvskj@…</author> <pubDate>Sun, 08 Jul 2012 11:22:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5928#comment:6" title="Comment 6">hugh.m.bright@…</a>: </p> <blockquote class="citation"> <p> I can reproduce this as well, the only difference beteween my "works" machine and "doesnt works" machine is the version of libstdc++ involved. </p> <p> Following <a class="ext-link" href="http://stackoverflow.com/questions/10354636/how-do-you-find-what-version-of-libstdc-library-is-installed-on-your-linux-mac"><span class="icon">​</span>http://stackoverflow.com/questions/10354636/how-do-you-find-what-version-of-libstdc-library-is-installed-on-your-linux-mac</a> </p> <p> strings /usr/lib/libstdc++.so.6 | grep GLIBCXX </p> <p> Machine that doesn't work: list stops with GLIBCXX_3.4.13 Machine that does work: list stops with GLIBCXX_3.4.16 </p> <p> Test program to demonstrate crash: </p> <p> #include &lt;boost/filesystem.hpp&gt; main() { boost::filesystem::path fp = boost::filesystem::current_path(); } </p> </blockquote> <p> But what does it tell about glibc version in your case? Please, try also </p> <blockquote> <p> strings /usr/lib/libstdc++.so.6 | grep GLIBC </p> </blockquote> <p> for this... </p> <p> Thanks. </p> </description> <category>Ticket</category> </item> <item> <author>dzinn@…</author> <pubDate>Thu, 09 Aug 2012 22:01:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:8</guid> <description> <p> I can confirm the bug. Is there a patch available? </p> <p> My GLIBC version goes up to 3.4.16. Other details of my system are: </p> <p> libboost_filesystem.so.1.49.0 <br /> </p> <p> gcc version 4.6.1 (<a class="missing wiki">Ubuntu/Linaro</a> 4.6.1-9ubuntu3)<br /> </p> <p> Ubuntu 11.10 <br /> </p> <p> Linux 3.1.0-1-amd64 <br /> </p> <p> strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX | grep 3.4.16<br /> </p> <p> GLIBCXX_3.4.16 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Fri, 22 Feb 2013 13:24:24 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5928#comment:9 https://svn.boost.org/trac10/ticket/5928#comment:9 <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> </ul> <p> Boost.Filesystem's implementation of path locale and codecvt handling has been rewritten with much simpler, more portable, and hopefully more robust code. The interface has not changed. The rewrite has been applied to svn trunk as of revision 83062. An added reference documentation section (boost-root/libs/filesystem/doc/reference.html#path-Usage) describes class path usage concerns, such as thread data races. </p> <p> These changes should resolve this issue. If you believe it has not been resolved satisfactorily, please open a new issue rather than reopening this issue. But before you do that, please reread boost-root/libs/filesystem/doc/reference.html#path-Usage to be sure that the problem you are seeing is not a manifestation of one of the those concerns. If you do open a new issue, please be specific and supply a test case and lots of details. Just saying something "doesn't work" or "crashes" is not enough! </p> <p> Thanks, </p> <p> --Beman </p> Ticket sleary@… Wed, 16 Jul 2014 10:36:11 GMT <link>https://svn.boost.org/trac10/ticket/5928#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:10</guid> <description> <p> Which release is revision 83062? </p> <p> I see this behaviour on Solaris on 1.49. A call to unique_path() when LC_ALL is not set to C causes a crash as described above. Will attempt to verify on a later version. </p> </description> <category>Ticket</category> </item> <item> <author>orangetinyterror@…</author> <pubDate>Fri, 18 Jul 2014 11:58:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5928#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5928#comment:11</guid> <description> <p> For what it's worth, I was hitting this with version 1.51.0 when passing a char[] to any API that implicitly constructs a path. There is a template constructor that seems to jump into the locale-resolution stuff (codecvt, etc...). </p> <p> Casting to or creating a const char * or a std::string seems to bypass that works as expected. </p> <p> For example: </p> <pre class="wiki">char dir[] = "/some/path"; boost::filesystem::exists( dir ); // runtime exception, perhaps dependent on env. locale boost::filesystem::exists( std::string( dir ) ); // works </pre><p> There's a comment in path.hpp about this, so I'm not sure it should be called a bug or not... </p> <p> Hope this helps. </p> </description> <category>Ticket</category> </item> </channel> </rss>