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

BUG: Fix small valgrind-found issues #18651

Merged
merged 3 commits into from Mar 20, 2021
Merged

Conversation

seberg
Copy link
Member

@seberg seberg commented Mar 19, 2021

This should be backportable. There was at least one that I could
not reproduce when running the tests again. And the new random-shuffle
tests give false-positives (which is just slightly annoying, considering
that we are very close to almost only "longdouble" related
false-positives)


I don't think this touches any code modified in the main branch. So it should be backported to 1.20. I may have to run pytest-leaks... (although leaks found there but not with valgrind are unlikely to cause much trouble in the wild...)

This should be backportable. There was at least one that I could
not reproduce when running the tests again. And the new random-shuffle
tests give false-positives (which is just slightly annoying, considering
that we are very close to almost only "longdouble" related
false-positives)
@seberg seberg added 00 - Bug 09 - Backport-Candidate PRs tagged should be backported labels Mar 19, 2021
The missing decref here only leaks references and can never leak
actual memory fortunately.
if (dict == NULL) {
return NULL;
}
/**begin repeat
* #str = func, var, func_xb, var_xb#
*/
item = PyUnicode_FromString(highest_@str@);
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the original was OK. Could move the declaration/assignment down here.

Copy link
Member Author

Choose a reason for hiding this comment

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

The code is in a /**begin repeatloop. I missed that also first, but that means it gets repeated 3 times. The (completely fine) alternative would be to put a Py_DECREF at the end of the loop.

Which, in hindsight is probably prettier...

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed a commit to simplifiy this, no need for the big SETREF gun...

@@ -7486,7 +7486,7 @@ def test_out_of_order_fields(self):
memoryview(arr)

def test_max_dims(self):
a = np.empty((1,) * 32)
Copy link
Member

Choose a reason for hiding this comment

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

Was there a problem with empty? I agree ones is nicer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Its a harmless "use of uninitialized memory" in valgrind because check_roundtrip actually does something with the values (or at least it looks like it).

Using SETREF can be nice, but was just overcomplicating thing here...
@charris
Copy link
Member

charris commented Mar 20, 2021

I cannot figure out what this does with the item (list), NPY_CPU_DISPATCH_CALL_ALL(_umath_tests_dispatch_attach, (item));, but if valgrind is happy I guess it isn't leaking a reference. Not that it would worry me much...

@charris charris merged commit 2ccc794 into numpy:main Mar 20, 2021
@charris
Copy link
Member

charris commented Mar 20, 2021

Thanks Sebastian.

@seberg
Copy link
Member Author

seberg commented Mar 20, 2021

Oh, yeah. valgrind seemed happy, so I was. I missed that list wasn't decref'd when there isn't an error. I guess the next bunch of small fixes might include that, this is testing code anyway.

@seberg seberg deleted the small-valgrind-fixes branch March 20, 2021 12:15
charris pushed a commit to charris/numpy that referenced this pull request Mar 21, 2021
* BUG: Fix small valgrind-found issues

This should be backportable. There was at least one that I could
not reproduce when running the tests again. And the new random-shuffle
tests give false-positives (which is just slightly annoying, considering
that we are very close to almost only "longdouble" related
false-positives)

* BUG: Add missing decref in user-dtype fallback paths

The missing decref here only leaks references and can never leak
actual memory fortunately.

* MAINT,TST: Simplify the "refcount logic" in the dispatch tests again

Using SETREF can be nice, but was just overcomplicating thing here...
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Mar 21, 2021
charris added a commit that referenced this pull request Mar 21, 2021
BUG: Fix small valgrind-found issues (#18651)
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.

None yet

2 participants