-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Check for output offsets int32 overflow in list APIs #23652
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
Open
davidwendt
wants to merge
6
commits into
NVIDIA:main
Choose a base branch
from
davidwendt:interleave-list-overflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+15
−9
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9461695
Check for output offsets int32 overflow in list APIs
davidwendt 4b17e1e
Merge branch 'main' into interleave-list-overflow
davidwendt d0224f4
Merge branch 'main' into interleave-list-overflow
davidwendt 9b5344d
commit
davidwendt 5e8446b
Merge branch 'main' into interleave-list-overflow
davidwendt a6a934f
Merge branch 'main' into interleave-list-overflow
davidwendt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 50368
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 9289
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 44025
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 41672
🏁 Script executed:
Repository: NVIDIA/cudf
Length of output: 463
Widen the per-row reduction before scanning.
reduce_by_key_asyncusessize_type(int32_t) for bothcuda::std::plus<size_type>()and theoffsetsoutput. A row-size sum aboveINT32_MAXcan wrap beforesizes_to_offsets, so the laterint64_tscan can validate truncated data. Reduce into anint64_ttemporary withcuda::std::plus<int64_t>(), then pass it tosizes_to_offsetsand retain this check.🤖 Prompt for AI Agents
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.
The values computed in
reduce_by_key_asyncand stored inoffsetsshould never exceedsize_typetoday. The code logic will need to be changed in a future PR whensize_typeis also changed and large lists are supported which is out of scope for this PR.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.
@davidwendt, thanks for the clarification. The currentsize_typelimit prevents the per-row reduction from exceedingint32_t. The widening change applies only after large-list support changes that invariant. I am withdrawing this finding.Would you like to open a follow-up issue for the future large-list update?
🐇
✏️ Learnings added
✅ Review thread resolved.
You are interacting with an AI system.
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.
Not necessary. There is already issues, etc that should cover this.
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.
@davidwendt, acknowledged. No follow-up issue is needed.🧠 Learnings used
✅ Review thread resolved.
You are interacting with an AI system.
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.
I don't think this statement is true? Consider concatenating two columns each with a single list entry with
size_typeelements. Both of these will end up in the same group and their offsets ought to end up as [0, size_type::max * 2], no?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.
The
reduce_by_keyhere just computes the sizes not the offsets. Yes, the sizes are stored in the variable named offsets temporarily. The largest value of each reduce should be[size_type::max, size_type::max, ...]I'm adding a check to make sure
input.columns() * input.row()does not exceedsize_type::maxThere 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.
Perhaps I am being dumb here. But suppose we have this input to concatenate rows
And suppose
K = size_type::max() - 1(andN - K + 1similarly).So
col_ahas offsets (up to off-by-one in my exposition)[0, K]andcol_bhas offsets[0, N - (K + 1)].So
concattedmust have offsets[0, N - 1], and the single row must haveN - 1entries in it. So I think that the reduce_by_key sees (in the same group)Kand(N - (K + 1)), so as soon asN - 1 > size_type::max()we have overflow?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.
I suspect this needs to happen directly in
concatenate_rows(since the gather on line 279 also does the same product).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.
Seems the number of entries within adjacent rows could result in an overflow for that row. I believe this could happen if you the child sizes themselves are near size_type::max and checking the number of parent rows would not be enough. Essentially the concat of the underlying children (which is necessary for this) would exceed size_type::max in kind of normal way. I'm not sure if that is checked somewhere before this is called.
I can certainly look into that in a follow-on PR.