Opened 12 years ago
Closed 8 years ago
#4688 closed Bugs (fixed)
std::runtime_error: locale::facet::_S_create_c_locale name not valid
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | Boost 1.56.0 | Component: | filesystem |
Version: | Boost 1.52.0 | Severity: | Showstopper |
Keywords: | Cc: |
Description
Try to compile empty program: int main() {} And link it with boost_filesystem
This program will crash throwing exception "std::runtime_error: locale::facet::_S_create_c_locale name not valid" on some systems (FreeBSD and some linuxes) when current locale (LANG,LC_ALL) is not "C"
Systems are known to be affected: DragonFly BSD with boost 1.44 from pkgsrc FreeBSD 7.2-RELEASE with boost 1.44 may be suse linux: Sles 10 sp3 with boost 1.44
Locally, we have to use attached patch as workaround.
Attachments (4)
Change History (34)
by , 12 years ago
Attachment: | boost_filesystem.patch added |
---|
by , 12 years ago
Attachment: | boost_filesystem.2.patch added |
---|
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Happens on Solaris 10 (Sun OS 5.10) with gcc-4.2.3 too. Empty program linking against boost_filesystem throws exact same exception. The patch provided fixed the problem.
comment:5 by , 11 years ago
Is there any information, when this bug will be fixed? This bug makes boost::filesystem unusable in production environment.
comment:6 by , 11 years ago
Still happens with Ubuntu 11.04/g++-4.5.2 and debian with g++/4.4.5. This is a very critical bug for production software as the application can only be started by overriding the locale on the command line (standard C locale seems to work; any other not).
comment:7 by , 11 years ago
Status: | new → assigned |
---|
I've been working on 4688, 5289, 5100, etc. all week. I'll post a status update on the main list, rather than try to reply to each ticket individually.
--Beman
comment:8 by , 11 years ago
I've had this same issue with gcc 4.5.2 and 4.5.3 on Ubuntu 8.04 and 10.04.3 (Boost 1.44.0).
Thanks for getting it sorted :)
-Keith
comment:10 by , 11 years ago
Have you tried 1.47.0?
The critical part of these three issues was fixed, and you should no longer have the problem at startup time.
The issues are about to be closed.
Thanks,
--Beman
comment:11 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed by changeset 72855, Fix problem of locale("") exception being thrown before main() starts on misconfigured (e.g. LANG="bad name") POSIX systems. Resolves the most serious aspect of tickets 4688, 5100, 5289.
Boost 1.47.0 was the first release to include this fix.
--Beman
comment:12 by , 11 years ago
Hey,
Went to give 1.47.0 a shot but had some incompatibilities with our code that need to be addressed.
Thanks -Keith
follow-up: 15 comment:13 by , 11 years ago
I tried it with boost 1_47 but is still happen the same on FreeBSD 8.1, doesn't work with locale en_US.UTF-8 nor with C (which was working with boost 1_46_1).
There was some compatibility issues (private functions that before were public and boost::asio::const_buffer_1 doesn't accept std::string anymore as constructor's parameter)
comment:14 by , 11 years ago
Hey,
Yeah we're having the same issues reported by multiple people with 1.47.0.
We've had to force LC_ALL=C in our launcher to avoid it, but this really isn't a nice way about it.
Any thoughts/suggestions? Thanks -Keith
follow-up: 16 comment:15 by , 11 years ago
Replying to gonzalo.raposo@…:
I tried it with boost 1_47 but is still happen the same on FreeBSD 8.1, doesn't work with locale en_US.UTF-8 nor with C (which was working with boost 1_46_1).
What is the "it" you are trying? Could you post code that fails?
And exactly what happens? Are you saying that the app still throws an exception before main starts?
Thanks,
--Beman
follow-up: 17 comment:16 by , 11 years ago
Replying to anonymous:
Replying to gonzalo.raposo@…:
I tried it with boost 1_47 but is still happen the same on FreeBSD 8.1, doesn't work with locale en_US.UTF-8 nor with C (which was working with boost 1_46_1).
What is the "it" you are trying? Could you post code that fails?
And exactly what happens? Are you saying that the app still throws an exception before main starts?
Thanks,
--Beman
Yes, it means that the app is still trowing the exception before main starts when locale != C. What you need to reproduce this issue is just create a simple main that uses boost.filesystem and the locale is another than C (en_US.UTF-8 for example)
Gonzalo
comment:17 by , 11 years ago
Replying to anonymous:
Replying to anonymous:
Replying to gonzalo.raposo@…:
I tried it with boost 1_47 but is still happen the same on FreeBSD 8.1, doesn't work with locale en_US.UTF-8 nor with C (which was working with boost 1_46_1).
What is the "it" you are trying? Could you post code that fails?
And exactly what happens? Are you saying that the app still throws an exception before main starts?
Thanks,
--Beman
Yes, it means that the app is still trowing the exception before main starts when locale != C. What you need to reproduce this issue is just create a simple main that uses boost.filesystem and the locale is another than C (en_US.UTF-8 for example)
Gonzalo
I have came across the same problem, only I am using a cross compiler. The true issue lies in how GCC (libstdc++) is configured. On some Linux distributions and apparently FreeBSD, the C++ runtime is configured to use generic locale support. This is the one that handles nothing but "C". However, if one configures GCC with "--enable-clocale=gnu", a more advanced implementation becomes available. I don't know if it's tied in any way to the GNU C library (it doesn't appear to) and I also don't know the proper way to check if you have "generic" or "gnu" enabled. I used
$ objdump -D -C -j .text -M intel libstdc++.so.6 >libstdc++.so.6.S
to look in the assembler dump for _S_create_c_locale(). A call to "newlocale@plt" tells me I have "gnu" enabled.
by , 11 years ago
Attachment: | boost_1_47_0_filesystem_freebsd.patch added |
---|
boost filesystem patch to include FreeBSD in the list of BSD platforms (!) that need locale fix
comment:19 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | Boost 1.44.0 → Boost 1.52.0 |
Same problem in HPUX with gcc44
follow-up: 23 comment:20 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
follow-up: 22 comment:21 by , 10 years ago
I have came accoss the same problem . GCC 4.1.0 SUSE LINUX 10.1 (x86-64) VERSION =10.1
follow-up: 24 comment:22 by , 10 years ago
Replying to hours10000@…:
I have came accoss the same problem . GCC 4.1.0 SUSE LINUX 10.1 (x86-64) VERSION =10.1
PS; boost 1.53
follow-up: 25 comment:23 by , 10 years ago
Replying to bemandawes:
This change (83083) is not totally correct. As you can see in the patch by bapt added at 6 February, there are three lines where the change should be done, however only two of them were changed in this changeset. I also figured out that for HP-UX a similar procedure solves the problem.
Please do replace the following string (three occurrences):
defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
with this one:
defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) || defined(__FreeBSD__) || defined(__hpux)
I'd also like to point out another fix I asked (misspelled macro name
_INCLUDE_STDC__SOURCE_199901
), related to ticket #5048 (I added a comment to the ticket)
Thank you very much.
comment:24 by , 10 years ago
Replying to hours10000@…:
Replying to hours10000@…:
I have came accoss the same problem . GCC 4.1.0 SUSE LINUX 10.1 (x86-64) VERSION =10.1
PS; boost 1.53
You need to test against svn trunk. The fix changeset was applied after 1.53 shipped.
--Beman
comment:25 by , 10 years ago
Replying to ruipfernandes@…:
Replying to bemandawes:
This change (83083) is not totally correct. As you can see in the patch by bapt added at 6 February, there are three lines where the change should be done, however only two of them were changed in this changeset.
The current svn trunk, which is what the fix was applied against, has only two occurrences.
I also figured out that for HP-UX a similar procedure solves the problem.
Please do replace the following string (three occurrences):
defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)with this one:
defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) || defined(__FreeBSD__) || defined(__hpux)
I'm nervous about adding HP-UX. Are you sure that all HP-UX systems use UTF-8 encoding? Do you have a link to HP docs on that?
I'd also like to point out another fix I asked (misspelled macro name
_INCLUDE_STDC__SOURCE_199901
), related to ticket #5048 (I added a comment to the ticket)
I'll take a look. Thanks,
--Beman
follow-ups: 27 29 comment:26 by , 9 years ago
Resolution: | fixed |
---|---|
Severity: | Problem → Showstopper |
Status: | closed → reopened |
Complete fuckup. Setting any LANG makes Ubuntu unusable. On my 12.04:
export LANG=de export LANG=en_US export LANG=en_US.UTF-8
makes every subsequent program crash with the boost crazyness.
comment:28 by , 8 years ago
Using boost 1.52 on gentoo, I got the same error message. Google landed me here.
I had LANG=en_US.UTF-8. Doing unset LANG and then re-running my application worked.
comment:29 by , 8 years ago
Replying to hendrich@…:
Complete fuckup. Setting any LANG makes Ubuntu unusable. On my 12.04:
export LANG=de export LANG=en_US export LANG=en_US.UTF-8
makes every subsequent program crash with the boost crazyness.
You are quite wrong, Ubuntu 12.04 has boost version 1.48 which already has this bug fixed. Still your application may crash but if it does it is bug in your application and not in boost, bug which coincidentally manifests itself the same way.
Original bug in boost was an exception thrown in initialization of global object, which happened before main() and hence was (almost) impossible to handle in programmatic way.
Since forementioned initialization was turned into lazy initialization, the same exception, which by the way is quite valid, can be handled programmaticaly.
This bug should be marked as fixed.
comment:30 by , 8 years ago
Milestone: | To Be Determined → Boost 1.56.0 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
std::runtime_error: locale::facet::_S_create_c_locale name not valid
exceptions may be caused by Boost.Filesystem errors, user program errors, or user system configuration errors. Comments on this thread mixed all three types of errors, making the thread hard to parse.
Please do not reopen this thread. Please open a new issue if you encounter a Boost.Filesystem error in 1.56.0 and it is not already described in another open filesystem issue. Please include a test program that illustrates the error, with instructions as to how to build and execute the program. Please do not bother to report locale and codecvt related errors in versions prior to 1.56.0 unless they also occur in 1.56.0, which made important changes locale and codecvt handling.
Thanks,
--Beman
This affected my system as well. The attached patch fixed the problem. I'm running Ubuntu 9.04 and used gcc-4.3 to compile. I downloaded the newest release (Boost 1.45.0) that was released today.