Skip to content
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

replace fmt::format with abseil #9623

Closed
derekargueta opened this issue Jan 9, 2020 · 7 comments
Closed

replace fmt::format with abseil #9623

derekargueta opened this issue Jan 9, 2020 · 7 comments
Labels
design proposal Needs design doc/proposal before implementation stale stalebot believes this issue/PR has not been touched recently tech debt

Comments

@derekargueta
Copy link
Member

Abseil has all the string processing functionality we need, this would allow us to remove a dependency.

@mattklein123 mattklein123 added design proposal Needs design doc/proposal before implementation tech debt labels Jan 9, 2020
@mattklein123
Copy link
Member

@derekargueta I would discuss with @jpeach who was also looking into this. FWIW unless we have a plan to replace it also in logging (it is baked into spdlog pretty heavily) I don't see a huge amount of value in the churn here. If we can replace it everywhere that would be nice.

@derekargueta
Copy link
Member Author

derekargueta commented Jan 9, 2020

Yeah the idea for this was actually from a slack message @jpeach posted a while ago in #envoy-dev.

I was able to knock out a lot of easy conversions from fmt::format("some string: {}", foo); to absl::StrCat("some string: ", foo); with a regex transform from:
fmt::format\("(([A-z]|\s)*)\{\}",\s(([A-z]|\.|_|\(|\))*)\);
to
absl::StrCat("$1", $3);
But for the more involved format templates we'll definitely need something a little more complex.

@jpeach
Copy link
Contributor

jpeach commented Jan 9, 2020

There's clang tooling to do this here: https://github.com/jpeach/rewrite-fmt-format.
Previous discussion in #8963

There are a very few places (maybe 5) that use fmt formatting specifiers other than "{}". These need to be done by hand. There are also a couple of cases where the format string isn't a literal, which also need to be done by hand.

@stale
Copy link

stale bot commented Feb 8, 2020

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Feb 8, 2020
@stale
Copy link

stale bot commented Feb 15, 2020

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Feb 15, 2020
htuch pushed a commit that referenced this issue May 15, 2020
Fixes fuzz crashes in fmt::format (https://github.com/fmtlib/fmt/blob/0463665ef136d685fe07a564d93c782456456d3d/include/fmt/format.h#L703) on certain invalid protobuf inputs. fmt is patches with PR (fmtlib/fmt#1650) that replaces the in-house fuzzing resource management to an fmt specific fuzzing macro.
Additional Description: The regression test added shows that the proto in question is not unreasonably huge for Envoy. This is causing a high unexplained crash percentage for many fuzz tests on OSS-Fuzz. Also bump fmt.

Testing: Added regression test in server fuzz test, failed
bazel test test/server:server_fuzz_test --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION before
Related: #9623
Risk level: Low

Signed-off-by: Asra Ali <[email protected]>
@htuch
Copy link
Member

htuch commented May 29, 2020

Given that fmt is now in C++20, I think we should stick with fmt for the long term FWIW (CC @ahedberg)

@ahedberg
Copy link
Contributor

It is a little weird to have two formatting libraries, but probably not worth the churn. Maybe some rule like "use fmt in logging, use absl everywhere else" suffices.

If the ultimate goal is to remove dependencies, Abseil is releasing its own logging framework soonish, which could let us cut spdlog and fmt if we wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design proposal Needs design doc/proposal before implementation stale stalebot believes this issue/PR has not been touched recently tech debt
Projects
None yet
Development

No branches or pull requests

5 participants