Skip to content

fix(vnode): fix signed/unsigned comparison in vnodePreProcessSubmitMsg.#34733

Merged
guanshengliang merged 1 commit intomainfrom
fix/main/signed-unsigned
Mar 10, 2026
Merged

fix(vnode): fix signed/unsigned comparison in vnodePreProcessSubmitMsg.#34733
guanshengliang merged 1 commit intomainfrom
fix/main/signed-unsigned

Conversation

@xiao-77
Copy link
Contributor

@xiao-77 xiao-77 commented Mar 10, 2026

Description

Issue(s)

https://project.feishu.cn/taosdata_td/defect/detail/6779910096
https://project.feishu.cn/taosdata_td/defect/detail/6779837756
https://project.feishu.cn/taosdata_td/defect/detail/6779880209

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Copilot AI review requested due to automatic review settings March 10, 2026 06:00
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 addresses potential issues arising from signed and unsigned integer comparisons within critical data processing loops in the vnode component. By updating the loop counter types, it ensures correct iteration behavior and prevents unexpected comparisons that could lead to bugs or warnings, thereby improving the robustness and reliability of data submission processing.

Highlights

  • Type Correction: Changed loop counter variables in vnodePreProcessSubmitTbData and vnodePreProcessSubmitMsg from signed integers (int32_t) to unsigned integers (uint32_t or uint64_t) to resolve signed/unsigned comparison issues.

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

Changelog
  • source/dnode/vnode/src/vnd/vnodeSvr.c
    • Updated loop counter types in vnodePreProcessSubmitTbData to uint32_t.
    • Updated loop counter type in vnodePreProcessSubmitMsg to uint64_t.
Activity
  • No human activity has been recorded on this pull request yet.
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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes signed/unsigned comparison warnings in vnode submit preprocessing by adjusting loop counter types during submit request decoding and row/key validation.

Changes:

  • Updated loop counter types in vnodePreProcessSubmitTbData() when iterating decoded column/row counts.
  • Updated loop counter type in vnodePreProcessSubmitMsg() to match nSubmitTbData’s unsigned width.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

for (int32_t iRow = 0; iRow < colData.nVal; iRow++) {
for (uint32_t iRow = 0; iRow < colData.nVal; iRow++) {
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

colData.nVal is an int32_t (see SColData), but the loop index was changed to uint32_t. This introduces a signed/unsigned comparison and can misbehave if nVal is ever negative (it would be converted to a large unsigned value). Prefer keeping the index signed to match nVal, or explicitly validate that nVal >= 0 before casting both sides to an unsigned type.

Suggested change
for (uint32_t iRow = 0; iRow < colData.nVal; iRow++) {
for (int32_t iRow = 0; iRow < colData.nVal; iRow++) {

Copilot uses AI. Check for mistakes.
}

for (int32_t iRow = 0; iRow < nRow; ++iRow) {
for (uint32_t iRow = 0; iRow < nRow; ++iRow) {
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

nRow is decoded as uint64_t, but the loop index was changed to uint32_t. If nRow exceeds UINT32_MAX, iRow will wrap and the loop condition will remain true, leading to an effectively unbounded loop (and likely out-of-bounds reads as pCoder->pos advances). Use a uint64_t/size_t index to match nRow, or cap/validate nRow to a safe maximum before iterating.

Suggested change
for (uint32_t iRow = 0; iRow < nRow; ++iRow) {
for (uint64_t iRow = 0; iRow < nRow; ++iRow) {

Copilot uses AI. Check for mistakes.
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 aims to fix signed/unsigned comparison warnings by changing the types of loop variables. While the intention is good, one of the changes incorrectly introduces a signed/unsigned mismatch, and another only partially fixes the issue. I've provided suggestions to correct these.

Note: Security Review did not run due to the size of the PR.

}

for (int32_t iRow = 0; iRow < colData.nVal; iRow++) {
for (uint32_t iRow = 0; iRow < colData.nVal; iRow++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This change introduces a signed/unsigned comparison warning. The type of colData.nVal is int32_t, so the loop variable iRow should also be int32_t to avoid the warning. The original code was correct.

    for (int32_t iRow = 0; iRow < colData.nVal; iRow++) {

}

for (int32_t iRow = 0; iRow < nRow; ++iRow) {
for (uint32_t iRow = 0; iRow < nRow; ++iRow) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To fully resolve the signed/unsigned comparison and prevent potential overflow, the loop variable iRow should be of type uint64_t to match the type of nRow, which is declared as uint64_t on line 362. If nRow were to exceed the maximum value of a uint32_t, this loop would behave incorrectly.

    for (uint64_t iRow = 0; iRow < nRow; ++iRow) {

@guanshengliang guanshengliang merged commit 7c35f62 into main Mar 10, 2026
16 of 17 checks passed
@guanshengliang guanshengliang deleted the fix/main/signed-unsigned branch March 10, 2026 08:43
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.

3 participants