Skip to content

demon: leakage in fixed-tag-value-insert-stmt#34394

Open
freemine wants to merge 1 commit intotaosdata:mainfrom
freemine:freemine.leakage.fixed-tag-value
Open

demon: leakage in fixed-tag-value-insert-stmt#34394
freemine wants to merge 1 commit intotaosdata:mainfrom
freemine:freemine.leakage.fixed-tag-value

Conversation

@freemine
Copy link
Contributor

to demon:

  1. build tdengine
  2. run test:
    ./debug/build/bin/stmt2Test --gtest_filter=stmt2Case.stmt2_insert_fixed_tag_value
截屏2026-01-24 19 54 38

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @freemine, 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 primarily focuses on improving the stability and correctness of the stmt2 API by resolving identified memory leaks and enhancing resource management within its test suite. It also expands test coverage with a new test case designed to verify specific insertion scenarios involving fixed tag values and primary key timestamp ordering.

Highlights

  • Memory Leak Fixes: Addressed several memory leaks in stmt2Test.cpp by ensuring proper deallocation of dynamically allocated memory and closing of TAOS_STMT2 statements and TAOS connections.
  • Resource Management Improvements: Enhanced resource management by explicitly freeing TAOS_STMT2_FIELD structures after use in relevant test cases within stmt2Test.cpp.
  • New Test Case for Fixed Tag Value Inserts: Introduced a new test case, stmt2_insert_fixed_tag_value, to validate the behavior of stmt2 when inserting data with fixed tag values, specifically addressing potential issues with disordered primary key timestamps (TD-34123).

🧠 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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 effectively addresses several memory and resource leaks within the test suite by ensuring proper deallocation of resources. The changes are correct and improve the stability of the tests. I have a few minor suggestions to enhance code consistency and cleanliness.

ASSERT_STREQ(pFields[0].name, "tbname");
ASSERT_STREQ(pFields[1].name, "ts");

taos_stmt2_free_fields(stmt, pFields);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with other parts of the code where pFields is freed (e.g., lines 1220, 1255), it's good practice to set pFields to NULL after freeing it to prevent potential use-after-free issues.

      taos_stmt2_free_fields(stmt, pFields);
      pFields = NULL;

Comment on lines +4980 to +4982
int tag_i = 0;
int tag_l = sizeof(int);
int tag_bl = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variables tag_i, tag_l, and tag_bl are declared but not used in this test case. They should be removed to improve code clarity.

int t64_len[5] = {sizeof(int64_t), sizeof(int64_t), sizeof(int64_t), sizeof(int64_t), sizeof(int64_t)};
int coli[5] = {1, 4, 4, 3, 2};
int ilen[5] = {sizeof(int), sizeof(int), sizeof(int), sizeof(int), sizeof(int)};
char is_null[2] = {1, 1};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable is_null is declared but not used in this test case. It should be removed to improve code clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant