Avoid memory allocation in CryptoHash#9474
Merged
maskit merged 3 commits intoapache:masterfrom Mar 13, 2023
Merged
Conversation
maskit
commented
Mar 1, 2023
|
|
||
| private: | ||
| CryptoContextBase *_base = nullptr; | ||
| static size_t constexpr OBJ_SIZE = 256; |
Member
Author
There was a problem hiding this comment.
I thought I may be able to calculate the minimal size but realized that it requires including header files for SHA256 and MD5.
Member
There was a problem hiding this comment.
It would probably be good to have some test or debug logic that does calculate the minimum size.
Member
Author
There was a problem hiding this comment.
AC_CHECK_SIZEOF? Then maybe we can do std::max. Try it if you are interested.
| #if TS_ENABLE_FIPS == 0 | ||
| case MD5: | ||
| _base = new MD5Context; | ||
| static_assert(OBJ_SIZE > sizeof(MD5Context)); |
bryancall
approved these changes
Mar 13, 2023
Member
Author
|
[approve ci autest] |
cmcfarlen
pushed a commit
to cmcfarlen/trafficserver
that referenced
this pull request
Jun 3, 2024
* Avoid memory allocation in CryptoHash * Add static_assert to ensure _base is big enough * Fix static_assert condition
cmcfarlen
pushed a commit
to cmcfarlen/trafficserver
that referenced
this pull request
Jun 3, 2024
* commit 'c54a2e2b77151869ff014fbdc4c82cec0afcbb8c': (37 commits) Slight performance improvements before calling APIHooks::clear (apache#9480) libswoc: Update to 1.4.5 (apache#9522) CryptoContext: Clean up to avoid compiler problem. (apache#9521) Add TLSCertSwitchSupport (apache#9322) Add clang-format-tests to clang-format target (apache#9456) Adds the AR env variable to config.nice (apache#9515) Fix .asf.yaml (apache#9519) Hugepage config cleanup (apache#9479) Separate io_uring into a separate library. AIO in io_uring mode uses new io_uring lib. (apache#9462) Avoid memory allocation in CryptoHash (apache#9474) UnitParser: add unit parser support. (apache#9485) autest - Minor fix on the verifier_client test ext to allow setting only the http3 ports. (apache#9517) Remove support for port event polling (apache#9476) QUIC: Add support to configure UDP max payload limit. (apache#9486) Reduce the size of the APIHooks, eliminating enum gap (apache#9509) Add support for CMCD-Request header nor field to prefetch plugin (apache#9232) Eliminates padding from some common structs (apache#9481) Enable external file loading for sni.yaml. (apache#9501) Remove inactive include of IpMapConf.h (apache#9512) Cleanup: Remove RecModeT from the code. (apache#9487) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This partially reverts #8719. I think the memory leak is because of not calling the destructor of
CryptoContextBase. Although use ofnewanddeletemakes the code easy to understand, we should avoid the memory allocation.