-
Notifications
You must be signed in to change notification settings - Fork 79
Fix initialization crash for WTinyLFU when parameters are empty #296
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
Fix initialization crash for WTinyLFU when parameters are empty #296
Conversation
Summary of ChangesHello @AengusMcGuinness, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical initialization crash in the WTinyLFU cache algorithm. Previously, providing an empty string for eviction parameters would lead to a malformed parameter string and an application abort. The changes ensure robust handling of empty or null eviction parameters by supplying a correct default, thereby preventing the crash and allowing the cache to initialize successfully. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request correctly fixes a crash that occurs when initializing WTinyLFU with empty eviction parameters. The change properly handles both NULL and empty string cases for eviction_params. I have one suggestion to make the code slightly cleaner by using NULL to rely on the default parameters defined within WTinyLFU_init, which improves clarity and maintainability.
| if (eviction_params == NULL || eviction_params[0] == '\0') { | ||
| cache = WTinyLFU_init(cc_params, "window-size=0.01"); |
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.
While this change correctly fixes the crash with empty parameters, passing NULL to WTinyLFU_init would be a cleaner way to apply the default parameters. The WTinyLFU_init function is already designed to use DEFAULT_PARAMS when its cache_specific_params argument is NULL. This approach avoids redundant parsing and makes the intention of using default values more explicit.
if (eviction_params == NULL || eviction_params[0] == '\0') {
cache = WTinyLFU_init(cc_params, NULL);|
Thank you! |
|
It looks like there is a failed check |
|
thank you for the heads-up! I've pushed a new commit that fixes the trailing whitespace issue in the |
Description:
This PR fixes an abort error that occurs when WTinyLFU is initialized with an empty parameter string (e.g., using the
-e ""flag in the CLI).The issue was located in
cache_init.h, where the code attempted to append default parameters to the user input. When the input was empty, the code produced a malformed string with a leading comma:",window-size=0.01"Changes:
Updated the logic in
bin/cachesim/cache_init.hto check if eviction_params is NULL or an empty string ("").If empty, it now passes a clean default string (
"window-size=0.01") without a leading comma.This ensures the initialization sequence is syntactically correct for the internal parser.
Verification:
Command:
(libCacheSim) libCacheSim/_build (libCacheSim) % ./bin/cachesim ../data/cloudPhysicsIO.txt txt tinyLFU 100M -e ""Before:
After: