Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check dimensions of arrays passed to C++ #5246

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

Closed
wants to merge 2 commits into from

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Oct 15, 2015

Proposed fix for #5185.

This checks all arrays that must have particular dimensions to lessen the likelihood of addressing uninitialized memory.

This includes #5241. I waffled about that, but ultimately, I just can't buy that the behavior of Numpy's atleast_3d, or at least not for our use case here, so better to not use it. We could work around that behavior, but it gets rather messy. The changes here will at least turn the use of atleast_3d to pass arrays to the C++ side as an exception that we'll catch early, rather than accessing undefined memory.

Replaces #5241 and #5245 (but I'm not closing those just yet in case those approaches are ultimately preferred).

cimarronm and others added 2 commits October 14, 2015 20:31
This reverts commit 2f5a633.
numpy.atleast_3d does not convert an empty array properly.
Check the dimensions on arrays passed to C++ to ensure they are what we
expect.
@mdboom mdboom added this to the next point release (1.5.0) milestone Oct 15, 2015
@tacaswell
Copy link
Member

Should these also be checking NDIM?

@jkseppan
Copy link
Member

Pull request #5247 tries to catch the particular case of accessing arrays where some dimension is zero. It's not an alternative to this, more a complement, since it only checks one particular kind of error but does it for all users of array_view.

@mdboom
Copy link
Member Author

mdboom commented Oct 15, 2015

@tacaswell: NDIM is already checked in the array_view->set method (the number of dimensions is a template parameter to the array_view type).

#5247 is an interesting idea, though the bug it fixes should be less likely with this PR here. I'd like to really examine the performance implications of that before merging.

@mdboom
Copy link
Member Author

mdboom commented Oct 19, 2015

Closed in favor of #5274.

@mdboom mdboom closed this Oct 19, 2015
@mdboom mdboom deleted the uninited-data branch November 10, 2015 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants