Fix locale fallback and guard tests against invalid locale settings #6025

pull dexX7 wants to merge 3 commits into bitcoin:0.10 from dexX7:0.10-init-locale-fallback-tests changing 3 files +7 −3
  1. dexX7 commented at 4:37 PM on April 18, 2015: contributor

    This is a copy of #5950, but for the 0.10 branch.


    Unfortually a fallback to "C" locale via std::locale::global does not cover all scenarios with messed up environment locale settings and on Ubuntu 14.01 (with LANG=en_US.UTF-8, LANGUAGE=en_US, LC_* empty) setting LANG=invalid triggers a crash right at the start of bitcoind and bitcoin-qt.

    This also affects test_bitcoin and test_bitcoin-qt, which were not guarded at all.

    The PR expands the scope of the locale fallback and prevents crashes due to invalid locale settings of bitcoind, bitcoin-qt, test_bitcoin and test_bitcoin-qt.


    I used the RPC test test_locale.py to confirm the 0.10 branch is affected by bad locale environment settings in this build, and that this PR does what it should in another build.

    The test was not added to this PR, because it executes the Boost tests a few times, which seems too expensive and wasteful.

  2. Initialization: set fallback locale as environment variable
    The scope of `std::locale::global` appears to be smaller than `setenv("LC_ALL", ...)` and insufficient to fix messed up locale settings for the whole application.
    df45564cf0
  3. Initialization: setup environment before starting tests
    The environment is prepared by the main thread to guard against invalid locale settings and to prevent deinitialization issues of Boost path, which can result in app crashes.
    7494e0915b
  4. Initialization: setup environment before starting QT tests
    The environment is prepared by the main thread to guard against invalid locale settings.
    323de27f4b
  5. laanwj commented at 11:41 AM on April 20, 2015: member

    Thanks, utACK

  6. laanwj merged this on Apr 20, 2015
  7. laanwj closed this on Apr 20, 2015

  8. laanwj referenced this in commit 3a70613398 on Apr 20, 2015
  9. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-24 12:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me