-
Notifications
You must be signed in to change notification settings - Fork 423
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
[EXPORTER] Do not use regex in CleanUpString
because some implementations of STL may crash.
#2464
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2464 +/- ##
==========================================
+ Coverage 87.04% 87.06% +0.02%
==========================================
Files 199 199
Lines 6087 6087
==========================================
+ Hits 5298 5299 +1
+ Misses 789 788 -1 |
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.
There is a known issue with gcc and regexp:
// Regex support
#if (__GNUC__ == 4 && (__GNUC_MINOR__ == 8 || __GNUC_MINOR__ == 9))
# define OPENTELEMETRY_HAVE_WORKING_REGEX 0
#else
# define OPENTELEMETRY_HAVE_WORKING_REGEX 1
#endif
The code in exporter_utils.cc did not check for OPENTELEMETRY_HAVE_WORKING_REGEX
, probably causing the bug found.
About the fix,
For PrometheusExporterUtils::CleanUpString
, I totally agree that using 4 regexp in a row was overkill, and replacing regexp with custom code is much better.
About PrometheusExporterUtils::RemoveUnitPortionInBraces
,
leaving the code as is with the regexp will still fail in gcc 4.8 and 4.9.
Could the fix also reimplement RemoveUnitPortionInBraces(), to remove the usage of regex completely ?
Thanks, it use |
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.
Thanks for the fix.
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.
LGTM, thanks for the fix.
CleanUpString
because some implementations of STL may crash.CleanUpString
because some implementations of STL may crash.
Fixes #2463
Changes
PrometheusExporterUtils::CleanUpString
std::regex_replace
, because it allocate lessstd::string
objects.std::string
constructor instd::regex_replace
because some versions of gcc can not detect the types correctly.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes