-
Notifications
You must be signed in to change notification settings - Fork 35
Account for current pointer being outside of the buffer #316
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
Merged
Conversation
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 pull request was exported from Phabricator. Differential Revision: D65118896 |
scotts
pushed a commit
to scotts/torchcodec
that referenced
this pull request
Nov 4, 2024
Summary: D60461269 added `TORCH_CHECK` to catch negative values. This would catch the input argument `buf_size` being negative. However, it never caught the case of `bufferData->current` pointer being past `bufferData->size`. This is due to intricacies of C++ type rules. Both `current` and `size` are `size_t` (unsigned integers), which causes the subtraction to always be non-negative. [This example](https://www.programiz.com/online-compiler/3zokStBbD2TeP) demonstrates above well. If we only had `read` method the `current` would never be able to go past `size`, but we have `seek` method that can set `current` to arbitrary values. The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer. Reviewed By: scotts, ahmadsharif1 Differential Revision: D65118896
244a178
to
421f443
Compare
This pull request was exported from Phabricator. Differential Revision: D65118896 |
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 4, 2024
Summary: D60461269 added `TORCH_CHECK` to catch negative values. This would catch the input argument `buf_size` being negative. However, it never caught the case of `bufferData->current` pointer being past `bufferData->size`. This is due to intricacies of C++ type rules. Both `current` and `size` are `size_t` (unsigned integers), which causes the subtraction to always be non-negative. [This example](https://www.programiz.com/online-compiler/3zokStBbD2TeP) demonstrates above well. If we only had `read` method the `current` would never be able to go past `size`, but we have `seek` method that can set `current` to arbitrary values. The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer. Reviewed By: scotts, ahmadsharif1 Differential Revision: D65118896
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 5, 2024
Summary: D60461269 added `TORCH_CHECK` to catch negative values. This would catch the input argument `buf_size` being negative. However, it never caught the case of `bufferData->current` pointer being past `bufferData->size`. This is due to intricacies of C++ type rules. Both `current` and `size` are `size_t` (unsigned integers), which causes the subtraction to always be non-negative. [This example](https://www.programiz.com/online-compiler/3zokStBbD2TeP) demonstrates above well. If we only had `read` method the `current` would never be able to go past `size`, but we have `seek` method that can set `current` to arbitrary values. The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer. Reviewed By: scotts, ahmadsharif1 Differential Revision: D65118896
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 5, 2024
Summary: D60461269 added `TORCH_CHECK` to catch negative values. This would catch the input argument `buf_size` being negative. However, it never caught the case of `bufferData->current` pointer being past `bufferData->size`. This is due to intricacies of C++ type rules. Both `current` and `size` are `size_t` (unsigned integers), which causes the subtraction to always be non-negative. [This example](https://www.programiz.com/online-compiler/3zokStBbD2TeP) demonstrates above well. If we only had `read` method the `current` would never be able to go past `size`, but we have `seek` method that can set `current` to arbitrary values. The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer. Reviewed By: scotts, ahmadsharif1 Differential Revision: D65118896
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 5, 2024
Summary: D60461269 added `TORCH_CHECK` to catch negative values. This would catch the input argument `buf_size` being negative. However, it never caught the case of `bufferData->current` pointer being past `bufferData->size`. This is due to intricacies of C++ type rules. Both `current` and `size` are `size_t` (unsigned integers), which causes the subtraction to always be non-negative. [This example](https://www.programiz.com/online-compiler/3zokStBbD2TeP) demonstrates above well. If we only had `read` method the `current` would never be able to go past `size`, but we have `seek` method that can set `current` to arbitrary values. The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer. Reviewed By: scotts, ahmadsharif1 Differential Revision: D65118896
ahmadsharif1
approved these changes
Nov 5, 2024
scotts
added a commit
to scotts/torchcodec
that referenced
this pull request
Nov 5, 2024
Summary: D60461269 added `TORCH_CHECK` to catch negative values. This would catch the input argument `buf_size` being negative. However, it never caught the case of `bufferData->current` pointer being past `bufferData->size`. This is due to intricacies of C++ type rules. Both `current` and `size` are `size_t` (unsigned integers), which causes the subtraction to always be non-negative. [This example](https://www.programiz.com/online-compiler/3zokStBbD2TeP) demonstrates above well. If we only had `read` method the `current` would never be able to go past `size`, but we have `seek` method that can set `current` to arbitrary values. The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer. Reviewed By: ahmadsharif1 Differential Revision: D65118896
421f443
to
9384239
Compare
Summary: Pull Request resolved: pytorch#316 D60461269 added `TORCH_CHECK` to catch negative values. This would catch the input argument `buf_size` being negative. However, it never caught the case of `bufferData->current` pointer being past `bufferData->size`. This is due to intricacies of C++ type rules. Both `current` and `size` are `size_t` (unsigned integers), which causes the subtraction to always be non-negative. [This example](https://www.programiz.com/online-compiler/3zokStBbD2TeP) demonstrates above well. If we only had `read` method the `current` would never be able to go past `size`, but we have `seek` method that can set `current` to arbitrary values. The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer. Reviewed By: ahmadsharif1 Differential Revision: D65118896
9384239
to
7185963
Compare
This pull request was exported from Phabricator. Differential Revision: D65118896 |
1 similar comment
This pull request was exported from Phabricator. Differential Revision: D65118896 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary:
D60461269 added
TORCH_CHECK
to catch negative values. This would catch the input argumentbuf_size
being negative.However, it never caught the case of
bufferData->current
pointer being pastbufferData->size
. This is due to intricacies of C++ type rules. Bothcurrent
andsize
aresize_t
(unsigned integers), which causes the subtraction to always be non-negative.This example demonstrates above well.
If we only had
read
method thecurrent
would never be able to go pastsize
, but we haveseek
method that can setcurrent
to arbitrary values.The diff here makes sure that we actually catch these negative values and fail with reasonable error instead of segfaulting trying to read memory outside of the buffer.
Differential Revision: D65118896