-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
alloc debug overflow on size 0 #159
Comments
Size and align 0 are not supported. Should add this to asserts as nd doc. |
please don't assert if size is 0. just return an allocation error if possible, or at least do a checked sub and unwrap so it doesn't do weird stuff in release mode; but ideally just return an error and let the client decide if they want to crash the process? |
I don't want to add another error variant. Especially since we use error type from Doing checking sub and unwrapping is much worse than meaningful assert IMHO. |
ok, agreed assert better than debug overflow unwrap; even better it's caught even farther upstream, but yea. Is creating a buffer of size 0 in vulkan really a validation error? I would assume it wouldn't care; it should be able to hand out an infinite amount of 0 size buffers ; ) |
Yes. Creating buffers of size 0 is invalid usage. |
I think we can just add asserts in debug mode. |
@omni-viral Shouldn't the assert also be there in release? Since in release it will wrap and a bunch of unexpected things will happen? |
If it’s invalid usage for size 0 simple panic with error message is best imho, and then documenting this as a panics condition :) Asserts are for pre and post condition enforcement and author programmer errors |
@m4b std uses asserts for invalid inputs like out of bounds for some |
Out of bounds panics with bounds len violation message, last I checked. I’m sure there are asserts in vec but I can’t remember last time an assert violation bubbled up to the user but I could be mistaken. |
In any event I mostly care about fixing the debug overflow which wasn’t super helpful wrt tracking down cause, and I don’t really care if it’s a panic or assert, just a better error message. This is effectively a one line fix we’re talking about so maybe we should just add it :) |
if the size is 0, this will abort on a sub overflow in debug mode.
The text was updated successfully, but these errors were encountered: