-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
add check for invalid state in _growend!
slow-path
#53513
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
add check for invalid state in _growend!
slow-path
#53513
Conversation
Is there something special at exactly this point? Presumably there are many places that use these fields so what is so exceptional that this should be added right here? |
There aren't that many places that use these fields (there were none prior to 1.11 since the fields didn't exist). This sort of check also is only beneficial before modifications to the fields, of which there are fewer use cases. It would be possible to add this to |
Yes, heh, I meant in the new array code. Seems at least reasonable to have it in |
fair enough. Added. |
58abc3d
to
2841030
Compare
I think this is now ready to go. |
This only triggers in cases where the user has done something pretty bad (e.g. modified the size incorrectly, or calling
push!
from multiple threads on the same vector without a lock). I'm very unsure ifConcurrencyViolationError
is the right error to throw here, but I think most of the time, that is going to be the cause. This check is in the slow path because adding extra checks here is basically free (since it will run rarely, and will be batched with O(n) work to copy everything over). I also only included it forgrowend!
and not the other grow functions because almost all users doing bad things in a multithreaded context are likely onlypush!
ing rather than inserting at the front or arbitrary locations.