Skip to content
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

[GLUTEN_8475][VL] Fix C-style casts to C++-style #8474

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jkhaliqi
Copy link
Contributor

@jkhaliqi jkhaliqi commented Jan 8, 2025

What changes were proposed in this pull request?

False positives for Do not Cast
cpp/velox/compute/WholeStageResultIterator.cc:461
cpp/velox/compute/WholeStageResultIterator.cc:463](http://wholestageresultiterator.cc:463/)
cpp/velox/shuffle/VeloxSortShuffleWriter.cc:219
cpp/velox/tests/FunctionTest.cc:157
cpp/velox/shuffle/VeloxShuffleReader.cc:437
cpp/velox/shuffle/VeloxSortShuffleWriter.cc:347
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1049
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1040
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1102
cpp/velox/substrait/SubstraitToVeloxPlan.cc:1095

(Please fill in changes proposed in this fix)

(Fixes: #8475)

@github-actions github-actions bot added the VELOX label Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

Thanks for opening a pull request!

Could you open an issue for this pull request on Github Issues?

https://github.com/apache/incubator-gluten/issues

Then could you also rename commit message and pull request title in the following format?

[GLUTEN-${ISSUES_ID}][COMPONENT]feat/fix: ${detailed message}

See also:

@jkhaliqi jkhaliqi changed the title [VL] Change C-style casts to C++-style [GLUTEN_8475][VL] Change C-style casts to C++-style Jan 8, 2025
@jkhaliqi jkhaliqi changed the title [GLUTEN_8475][VL] Change C-style casts to C++-style [GLUTEN_8475][VL] Fix C-style casts to C++-style Jan 8, 2025
@@ -161,7 +161,7 @@ bool StdMemoryAllocator::reallocateAligned(void* p, uint64_t alignment, int64_t
return false;
}
if (newSize <= size) {
auto aligned = ROUND_TO_LINE(newSize, alignment);
auto aligned = ROUND_TO_LINE(static_cast<uint64_t> newSize, alignment);
Copy link
Member

Choose a reason for hiding this comment

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

is this a typo?

Copy link
Contributor Author

@jkhaliqi jkhaliqi Jan 9, 2025

Choose a reason for hiding this comment

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

Dont Use Cast@cpp/core/memory/MemoryAllocator.cc:164
looks like newSize is int64_t and alignment is uint64_t so i'm assuming there is some sort of casting that goes on when calling this function. With that I figured they should both go in with the same type. With the above line showing if (newSize <= 0) {return false;} im assuming newSize will be positive if it gets to here so I just casted it to be uint64_t like the alignment variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I did forget the parenthesis around newSize, updating!

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks.

It seems GitHub CI service is encountering issues so the CI is not triggering BTW.

@zhztheplayer
Copy link
Member

@jkhaliqi Would you fix the code style? Thanks!

https://github.com/apache/incubator-gluten/actions/runs/12682962050/job/35349998150?pr=8474

@@ -440,7 +440,7 @@ std::shared_ptr<ColumnarBatch> VeloxSortShuffleReaderDeserializer::deserializeTo
auto buffer = cur->second;
const auto* rawBuffer = buffer->as<char>();
while (rowOffset_ < cur->first && readRows < batchSize_) {
auto rowSize = *(RowSizeType*)(rawBuffer + byteOffset_) - sizeof(RowSizeType);
auto rowSize = *(static_cast<RowSizeType*>(rawBuffer + byteOffset_)) - sizeof(RowSizeType);
Copy link

Choose a reason for hiding this comment

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

Is there a reason that you don't use this one liner for other occurrences?
In other cases you are splitting it into two lines (first the ptr and then the dereference, for example, previous file line 186ff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No reason updating all to be one liner, thank you!

makeConstantExpr(INTEGER(), static_cast<int32_t>(678)),
makeConstantExpr(BIGINT(), static_cast<int64_t>(910)),
makeConstantExpr(REAL(), static_cast<float>(1.23)),
makeConstantExpr(BOOLEAN(), 1),
Copy link

Choose a reason for hiding this comment

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

What's wrong with these but not the last double cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed the last one, updated, thank you!

@jkhaliqi jkhaliqi force-pushed the jk_cve_cast branch 2 times, most recently from 89fb899 to 0dd6f9d Compare January 10, 2025 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VL] Security Voliations Do Not Cast
3 participants