WIP: common: Skip environment locale check on illumos #36399

Closed
hebasto wants to merge 1 commit from 261001-illumos-locale into master AGit
hebasto commented 2026-10-01 15:23:57 +00:00 (Migrated from github.com)

On illumos-based distributions whose GCC is built with the --enable-clocale=dragonfly option (e.g. OmniOS, OpenIndiana), the std::ctype<char>::~ctype() destructor passes an uninitialized value to freelocale().

Constructing and destroying std::locale("") in SetupEnvironment() therefore intermittently crashes, e.g. with "libc thread failure: lfree() called with a misaligned pointer".

Upstream reports:

Closes https://github.com/hebasto/bitcoin-core-nightly/issues/315.

On illumos-based distributions whose GCC is built with the `--enable-clocale=dragonfly` option (e.g. OmniOS, OpenIndiana), the `std::ctype<char>::~ctype()` destructor passes an uninitialized value to `freelocale()`. Constructing and destroying `std::locale("")` in `SetupEnvironment()` therefore intermittently crashes, e.g. with "libc thread failure: lfree() called with a misaligned pointer". Upstream reports: - https://github.com/illumos/gcc/pull/56#issuecomment-5933176361 - https://github.com/omniosorg/omnios-build/issues/4253 - https://www.illumos.org/issues/18481 Closes https://github.com/hebasto/bitcoin-core-nightly/issues/315.
DrahtBot commented 2026-10-01 15:24:05 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36399 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36399.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36399#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: 7988380da987c0b860885853ace8149b84ac2ee8
Head: ae156930118c9fda1cece3dfcff41820afdb4875

Design and approach

Confirm the locale-check exemption covers all illumos toolchains (src/common/system.cpp:75, head)

The condition skips the invalid-environment locale check for every illumos build, but the stated destructor crash concerns distributions using libstdc++'s dragonfly locale model. Previously, a failed std::locale("") check set LC_ALL to C.UTF-8, and Qt later calls setlocale(LC_ALL, "") during initialization (src/qt/bitcoin.cpp:203). An illumos build unaffected by the destructor bug may therefore lose this recovery for invalid LC_* settings. Please confirm that all supported illumos toolchains need the exemption, or restrict it to the affected runtime configuration if unaffected illumos toolchains are supported and still need the fallback.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `7988380da987c0b860885853ace8149b84ac2ee8` Head: `ae156930118c9fda1cece3dfcff41820afdb4875` ##### Design and approach **Confirm the locale-check exemption covers all illumos toolchains** (src/common/system.cpp:75, head) The condition skips the invalid-environment locale check for every illumos build, but the stated destructor crash concerns distributions using libstdc++'s dragonfly locale model. Previously, a failed `std::locale("")` check set `LC_ALL` to `C.UTF-8`, and Qt later calls `setlocale(LC_ALL, "")` during initialization (`src/qt/bitcoin.cpp:203`). An illumos build unaffected by the destructor bug may therefore lose this recovery for invalid `LC_*` settings. Please confirm that all supported illumos toolchains need the exemption, or restrict it to the affected runtime configuration if unaffected illumos toolchains are supported and still need the fallback. [Full review report](<https://review.fish.foo/traces/36399-ae156930118c9fda1cece3dfcff41820afdb4875-186-1.html>)
maflcko commented 2026-10-01 15:54:19 +00:00 (Migrated from github.com)

Why is all of this code needed (https://github.com/bitcoin/bitcoin/pull/4174#issue-33259538) in the first place? At this point it may be better to delete it (possibly move it to the GUI, if it is needed there)

Why is all of this code needed (https://github.com/bitcoin/bitcoin/pull/4174#issue-33259538) in the first place? At this point it may be better to delete it (possibly move it to the GUI, if it is needed there)
maflcko commented 2026-10-01 16:05:52 +00:00 (Migrated from github.com)
to clarify: boost fs has long been removed (https://github.com/bitcoin/bitcoin/issues/4147#issuecomment-42491986)
maflcko commented 2026-10-14 08:21:17 +00:00 (Migrated from github.com)
Let's close and move discussion to https://github.com/bitcoin/bitcoin/pull/36524 ?
hebasto commented 2026-10-14 08:22:25 +00:00 (Migrated from github.com)
Closing in favour of https://github.com/bitcoin/bitcoin/pull/36524.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36399
No description provided.