-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Check for overflow in Blob::Reshape #1584
Conversation
I'd still keep the old checks...even number of negative dimensions? |
092bf50
to
386d726
Compare
Previously, bad values for the dimensions could overflow count_, resulting in a silent failure to allocate.
386d726
to
f222a66
Compare
Right, I had a vague sense I was forgetting something... those checks are back now. |
cool, LGTM |
By the way, overflow can still occur undetected if it happens twice, so that the result is positive. On a related note, we need to change types if we want to be able to allocate blobs larger than 2GB. It seems like a good idea to change this function so that the allocation either succeeds correctly or fails immediately; currently if you ask for a blob of the wrong (large) size, you get a smaller blob and a headache instead (even with this PR). |
But Jon, users will never need blobs larger than 2 GB! Would checking for overflow after each multiply fix it? I can do that in #1486 when I'll have to loop over dimensions anyway if so. |
Not the way it's done here; |
Oh right, makes sense. Checking |
Replaced by #2426. |
The check onmore importantly includes the previously ignored case where bad values for the dimensions cause an overflow forcount_
is more succinct than checking the individual dimensions, andcount_
, resulting in a silent failure to allocate. Printing the dimension values ensures that no useful debugging information is lostin the change.