-
Notifications
You must be signed in to change notification settings - Fork 38.7k
doc: Document differences in bitcoind and bitcoin-qt locale handling #18817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: Document differences in bitcoind and bitcoin-qt locale handling #18817
Conversation
|
Concept ACK. Mind adding a link: https://doc.qt.io/qt-5/qcoreapplication.html#locale-settings or https://doc.qt.io/qt-5/qcoreapplication.html ? I'm confused a bit with wording "surprisingly" as such behavior is mentioned in Qt docs :) UPDATE: https://stackoverflow.com/questions/34877942/is-qt-forcing-the-system-locale could be relevant. |
040cda1 to
aac53b7
Compare
|
@hebasto Thanks a lot for reviewing! Good points: I've adjusted accordingly. Please re-review :) |
|
@practicalswift Why do you think that the |
|
@hebasto I put the comment in the I'm fine as long as we have it documented somewhere so that future generations of Bitcoin Core developers don't have to wonder where the heck the "invisible" |
It seems better to get a broader consensus :) |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
aac53b7 to
52d83bf
Compare
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
Perhaps add a paragraph similar to the second one in your PR description.
I'm not sure, but this might be a bit long for the developer notes. Maybe either in the codebase like here, or in its own file in /doc, the main thing being that a developer git grepping on the topic finds it easily.
Some suggestions below; feel free to pick and choose or ignore.
3ec8452 to
1bd43d1
Compare
|
The CI failure is most likely unrelated. Can someone restart the Cirrus CI job? :) |
|
Concept ACK FWIW, I agree with @hebasto and would only put a much shorter version of the comment in the code. My perspective is that a lot of people look at |
200bf0d to
26fa249
Compare
hebasto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 26fa24996e18b9ecaa1b21fcfd049af6c468d59d, I have reviewed the code and it looks OK, I agree it can be merged.
|
ACK 26fa24996e18b9ecaa1b21fcfd049af6c468d59d Restarted failing CI job. |
|
I think this one should be ready for merge now :) |
|
Ready for merge? :) |
Do you have one example handy where the different handling was the root cause for an issue? Also I am wondering what the motivation here is. While this difference in handling may be theoretically correct, we should never obverse it in practice. If we did, it would be a bug, as any locale dependent functions should be avoided. |
There are plenty but look at #6443: bug in Bitcoin Qt due to Qt's highly surprising "unsolicited" The thing is that literally all locale bugs when using POSIX functions have been due to this difference. If it wasn't for the We could literally kill the locale dependency bug class for good in Bitcoin Core by simply following the recommendation of the Qt documentation:
(Aside: AFAICT there is not a single place in our code base where we want the POSIX functions to use a locale other than So, why documenting this? A new developer coming to the project doing He or she might thus incorrectly assume that we don't risk running in to POSIX locale bugs. If this PR is merged he/she will hopefully fully understand why we run such risk despite the apparent lack of
If consensus critical code would use a POSIX locale dependent function the worst case scenario would be a chain split between Such a worst-case chain split would certainly be observable in practice :)
I share the long-term goal of removing all usages of locale dependent functions, but I don't see how that would be in conflict with wanting to document how locales are currently used in our project, and the risks such use entails :) Should I perhaps drop or rephrase the developer note comment? As long as we document this somehow and somewhere in a greppable way in our project I'm happy :) |
|
Ok, sounds reasonable. About the dev notes: I see them mostly as instructions on how we write code. "Avoid using locale dependent functions if possible" is already mentioned and the qt documentation seems a bit misplaced. Concept ACK |
26fa249 to
ca185cf
Compare
|
@MarcoFalke Thanks for reviewing! No longer touching the developer notes. Should hopefully be ready for merge :) |
hebasto
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK ca185cf
…n-qt locale handling ca185cf doc: Document differences in bitcoind and bitcoin-qt locale handling (practicalswift) Pull request description: Document differences in `bitcoind` and `bitcoin-qt` locale handling. Since this seems to be the root cause to the locale dependency issues we've seen over the years I thought it was worth documenting :) Note that 1.) `QLocale` (used by Qt), 2.) C locale (used by locale-sensitive C standard library functions/POSIX functions and some parts of the C++ standard library such as `std::to_string`) and 3.) C++ locale (used by the C++ input/output library) are three separate things. This comment is about the perhaps surprising interference with the C locale (2) that takes place as part of the Qt initialization. ACKs for top commit: hebasto: re-ACK ca185cf Tree-SHA512: e51c32f3072c506b0029a001d8b108125e1acb4f2b6a48a6be721ddadda9da0ae77a9b39ff33f9d9eebabe2244c1db09e8502e3e7012d7a5d40d98e96da0dc44
Summary: > Document differences in bitcoind and bitcoin-qt locale handling. > > Since this seems to be the root cause to the locale dependency issues we've seen over the years I thought it was worth documenting This is a backport of [[bitcoin/bitcoin#18817 | core#18817]] Test Plan: proofreading Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: boardgamesaz, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10136
Document differences in
bitcoindandbitcoin-qtlocale handling.Since this seems to be the root cause to the locale dependency issues we've seen over the years I thought it was worth documenting :)
Note that 1.)
QLocale(used by Qt), 2.) C locale (used by locale-sensitive C standard library functions/POSIX functions and some parts of the C++ standard library such asstd::to_string) and 3.) C++ locale (used by the C++ input/output library) are three separate things. This comment is about the perhaps surprising interference with the C locale (2) that takes place as part of the Qt initialization.