Update fdbserver to use fmt library consistently#12782
Update fdbserver to use fmt library consistently#12782tclinkenbeard-oai wants to merge 5 commits intoapple:mainfrom
fdbserver to use fmt library consistently#12782Conversation
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
gxglass
left a comment
There was a problem hiding this comment.
I personally don't find the {} stuff easier to read. I don't care about visual compatibility with python. Just tell me what the type is.
If we need to call format to print a complex data structure that's another question and I guess we can do that. But in general I'd rather read %d than {} in a format string
|
Also I looked at fmt.dev and it says "Errors in format strings, which are a common source of vulnerabilities in C, are reported at compile time. For example ... ". Pretty sure C and C++ compilers have been warning about this for about 25 years. If we can point to concrete examples where format string bugs have got through I would be interested to learn about it. |
I checked the bugs in the second commit. Those are existing calls to format where the wrong object is passed. Presumably something gets printed but we emit a confusing message. What I'm wondering about is actual vulnerabilities due to use of type-specific format strings. |
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
I don't feel super strongly about the above and would like the team to weigh in. |
I can't find any concrete examples in this PR, but one source of potential undefined behavior is foundationdb/fdbrpc/HTTP.actor.cpp Line 50 in d8fc979 c will be negative, and the sprintf call is undefined on some platforms.
|
One possibility is that the |
Ah yeah, somebody sent a security note about this. My view on this is that the original code is just unjustifiably wrong. Nobody should be typing sprintf in the 21st century. It should have been |
I'll address the sprintf in a separate PR. We keep getting security reports about this anyway. |
|
@spraza @saintstack Do you have any views on the fmt usage here? |
I do prefer explicit types. Also the DataDistributor commit is probably fixing a copy-paste bug, doesn't seem like it warrants fmt. On the plus side, maybe potential perf win, although we haven't measured. I do like the ability to reuse positional arguments. And finally, printing complex data structures should be easier. Overall I'm ok with the change, I think it's a net positive with lack of explicit types being the main downside, which we can address (e.g. |
This PR applies a similar
fmtrewrite tool as used in #12780, this time forfdbserver.While applying this rewrite, 2 bugs with invalid print statements were fixed in
DataDistribution.actor.cpp(in the second commit of this PR).Code-Reviewer Section
The general pull request guidelines can be found here.
Please check each of the following things and check all boxes before accepting a PR.
For Release-Branches
If this PR is made against a release-branch, please also check the following:
release-branchormainif this is the youngest branch)