Skip to content
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

FIX: protect stolen ref by PyArray_NewFromDescr in array_empty #8180

Merged
merged 1 commit into from
Oct 20, 2016

Conversation

rainwoodman
Copy link
Contributor

@rainwoodman rainwoodman commented Oct 19, 2016

This fixes #8179.

Valgrind warning is gone.

I checked other uses of PyArray_NewFromDescr in ctor.c all look healthy.

@ahaldane
Copy link
Member

LGTM.

The description of PyArray_NewFromDescr makes clear it sometimes immediately decrefs the descr, eg when a subarray is involved.

@ahaldane
Copy link
Member

ahaldane commented Oct 20, 2016

I don't think a test is needed, but @charris may want the commit message to say "BUG" instead of "FIX", see our standard prefixes, so I'll leave that to him.

Edit: And the commit message should say "fixes #8179"

@@ -2895,20 +2895,25 @@ PyArray_Empty(int nd, npy_intp *dims, PyArray_Descr *type, int is_f_order)
PyArrayObject *ret;

if (!type) type = PyArray_DescrFromType(NPY_DEFAULT_TYPE);

/* PyArray_NewFromDescr steals a ref,
* but we need to look at type later. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we are at nitpicking, the comment end should be formatted:

/*
 * Text here
 * more text
 */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or keep it on a single line ;)

@seberg
Copy link
Member

seberg commented Oct 20, 2016

Should try your valgrind commands, or is there some speical setup needed? For some reason, running numpy/python stuff through valgrind does not work for me anymore since a while....

@seberg
Copy link
Member

seberg commented Oct 20, 2016

Out of curiosity, did you run with a specially compiled python or do those valgrind options hide the typical python allocation spam?

@rainwoodman
Copy link
Contributor Author

@seberg For one, I updated to Fedora 24 and all of the allocation spam are gone. gdb supports python too. If that counts towards an answer...

@rainwoodman
Copy link
Contributor Author

@ahaldane messages updated.

@rainwoodman
Copy link
Contributor Author

@seberg : according to the changelog at http://koji.fedoraproject.org/koji/buildinfo?buildID=809980, Fedora has been compiling Python with valgrind support for a few years. The support may have just gotten better in 3.5, I guess.

@seberg
Copy link
Member

seberg commented Oct 20, 2016

Dunno, was using debian/ubuntu, it always worked (though I had to add suppressions, which probably would have hidden cases such as this one as well), have not tried it in a bit, but more recently things always crashed. But no worries, seems like other people run the testsuit through valgrind once in a while nowadays ;). I'll leave the merge to @ahaldane.

@ahaldane
Copy link
Member

Great, merging. Thanks @rainwoodman for the valgrind tests!

@ahaldane ahaldane merged commit bb59409 into numpy:master Oct 20, 2016
@rainwoodman
Copy link
Contributor Author

no problems!

@rainwoodman rainwoodman deleted the fix-8179 branch November 22, 2016 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refcount of dtype drops to zero in array_empty.
4 participants