You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Locale should default to C / Posix Environment #4147
Busybox does not use locales - bitcoin should set a default C / Posix environment. The following locale error:
EXCEPTION: St13runtime_error
locale::facet::_S_create_c_locale name not valid
bitcoin in AppInit()
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
The above patch is almost identical to the patch I proposed for Namecoin to fix this issue (Windows builds are unaffected):namecoin/namecoin-legacy#72 (comment)
If your system doesn't use locales, then setlocale(any, "" or NULL) should simply return "C", and setlocale(any, anything else) should return NULL. If that is causing problems in boost or bitcoind, those problems should be fixed rather than forcing the "C" locale.
Do we, in the current master version of bitcoin, have anything that generates this error?
If so, where is it raised? Where does the exception originate from? It must be some usage of boost. Can we avoid that, maybe by passing in our own locale object instead of using the system one?
I don't understand how this happens in the first place: boost raises this error if it cannot find the selected locale.
As @luke-jr says, the "C" locale is selected by default if you have not set another locale (so if LC_* is not set).
Where does it get this information from? Can you show your environment?
A C environment is not being set by default on bitcoin or namecoin - as already noted 'setlocale(LC_TIME, NULL)' does not force a C environment on Busybox (Alpine Linux)
you could also put the command in ~/.bashrc or in /etc/profile or /etc/default/locale
without exporting LC_ALL - what does 'echo $LC_ALL' or 'locale' give for LC_ALL ? (maybe something else on your system is setting it to an incompatible value for Bitcoin) - you would need to log off & on again to test this.
This is still an open issue in 0.10.1rc2 even though 0.10.0 was fine in the same environment:
EXCEPTION: St13runtime_error
locale::facet::_S_create_c_locale name not valid
bitcoin in AppInit()
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Aborted (core dumped)
@laanwj Not sure where to post, but AFAIK some change to locale handling was revert, which reintroduces a crash when chaning -txindex and aborting or when trying to abort Qt startup during init phase in splash screen... too bad this is unfixed again :-/.
Is this issue fixed or still present in 0.12 / master?
There have been more changes to this code since, so I suppose it is, but as the locale initialization is complex voodoo code there could always be an edge case.
Oh! If it was fixed back then I doubt it has come back now. Just wonder why the issue was never closed then.
But if you want to try on 0.12 just in case, thanks :)
Activity
laanwj commentedon May 7, 2014
Overwriting LC_ALL with a fixed value is quite an ugly solution (busybox may not use locales, but we do).
Isn't there something more specific that can be done about the boost error?
itoffshore commentedon May 7, 2014
I tried catching the error & then setting the environment without success
sipa commentedon May 7, 2014
Is this caused by the use time_input_facet in DecodeDumpTime in rpcdump.cpp?
itoffshore commentedon May 7, 2014
This error is thrown in AppInit() - setting LC_ALL in AppInit2() did not fix the problem
luke-jr commentedon May 7, 2014
If your system doesn't use locales, then setlocale(any, "" or NULL) should simply return "C", and setlocale(any, anything else) should return NULL. If that is causing problems in boost or bitcoind, those problems should be fixed rather than forcing the "C" locale.
itoffshore commentedon May 7, 2014
this was in bitcoinrpc.cpp in the namecoin sources but it did not force a C locale
laanwj commentedon May 7, 2014
You keep talking about namecoin.
Do we, in the current master version of bitcoin, have anything that generates this error?
If so, where is it raised? Where does the exception originate from? It must be some usage of boost. Can we avoid that, maybe by passing in our own locale object instead of using the system one?
Edit: I see we indeed use setlocale here: https://github.com/bitcoin/bitcoin/blob/master/src/rpcprotocol.cpp#L52 . That's not thread-safe at all. But it appears that the exception is raised at at start-up, so it cannot be caused by that.
itoffshore commentedon May 7, 2014
The exact error in Bitcoin is:
sipa commentedon May 7, 2014
And which code throws it?
itoffshore commentedon May 7, 2014
just running 'bitcoind --help' is enough to generate the error - any command will generate the same error on a machine without locales.
A default C locale should be set.
sipa commentedon May 7, 2014
I don't want an ugly workaround hack unless we know what code throws this error, and that there is no other way to avoid the problem.
laanwj commentedon May 7, 2014
I don't understand how this happens in the first place: boost raises this error if it cannot find the selected locale.
As @luke-jr says, the "C" locale is selected by default if you have not set another locale (so if LC_* is not set).
Where does it get this information from? Can you show your environment?
itoffshore commentedon May 7, 2014
A C environment is not being set by default on bitcoin or namecoin - as already noted 'setlocale(LC_TIME, NULL)' does not force a C environment on Busybox (Alpine Linux)
laanwj commentedon May 7, 2014
This may be the culprit if you don't have the en_US locale.
Can you try undefining it?
luke-jr commentedon May 7, 2014
It seems the way most software handles unknown locales is to ignore them. We should do the same...
22 remaining items
jl2035 commentedon Oct 27, 2014
yeah that's it. everytime i login i first have to run 'export LC_ALL=C' and than bitcoind works
itoffshore commentedon Oct 27, 2014
you could also put the command in ~/.bashrc or in /etc/profile or /etc/default/locale
without exporting LC_ALL - what does 'echo $LC_ALL' or 'locale' give for LC_ALL ? (maybe something else on your system is setting it to an incompatible value for Bitcoin) - you would need to log off & on again to test this.
jl2035 commentedon Oct 29, 2014
thanks.
"LC_ALL" is empty for some reason..
luke-jr commentedon Oct 29, 2014
It's normal for LC_ALL to be unset.
jl2035 commentedon Oct 30, 2014
ok.
it is working with LC_ALL set to "C", so I guess that's ok for me.. i also don't need this node for long..
adattudos commentedon Apr 16, 2015
This is still an open issue in 0.10.1rc2 even though 0.10.0 was fine in the same environment:
itoffshore commentedon May 6, 2015
Testing 0.10.1 there is no longer any
environmentregression.0.10.1 should also be patched as shown here to fix a segfault introduced in 0.10
Diapolo commentedon May 25, 2015
@laanwj Not sure where to post, but AFAIK some change to locale handling was revert, which reintroduces a crash when chaning -txindex and aborting or when trying to abort Qt startup during init phase in splash screen... too bad this is unfixed again :-/.
laanwj commentedon Feb 16, 2016
Is this issue fixed or still present in 0.12 / master?
There have been more changes to this code since, so I suppose it is, but as the locale initialization is complex voodoo code there could always be an edge case.
itoffshore commentedon Feb 16, 2016
This issue has been fixed since
0.10.1in Alpine Linux & also with0.11.xtoo.I will try building
0.12laanwj commentedon Feb 16, 2016
Oh! If it was fixed back then I doubt it has come back now. Just wonder why the issue was never closed then.
But if you want to try on 0.12 just in case, thanks :)
jl2035 commentedon Feb 16, 2016
I no longer run a full node, so I never reported back.
itoffshore commentedon Feb 16, 2016
0.12is fine too - this issue can be closed