-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: NumPy 2.3.0 regression - corrupted array values #29038
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
Comments
There is a bug here in that the commit shouldn't have changed anything but got the logic wrong and disabled the caching often! However, it's unclear that the underlying issue here is NumPy and not just made visible by this change. A possible place where this could arise is if you use I had hoped valgrind would throw something, but it didn't (with
(put the imports on their own, they'll probably create some false positives). Sanitizers are great, but valgrind has zero setup-cost if it works.
Yeah, and revert we should. But the problem is that this change is correct, there is an real underlying bug just hidden by the caching and if you just make the array larger you may always run into it. EDIT: Milestone for the revert, not to find an underlying issue (which I still think has a good chance of not being in NumPy). |
Didn't mean to auto-close, there is still an issue even if I think it is at least as likely to be an issue downstream. That said, I guess we can close it soon without follow up from you @user27182. Again the PR change wasn't a bug (except that it should have been a speed regression) it just made a bug more visible. |
This does appear to have resolved the issue with our failed test, thanks @seberg! I tested this fix locally but was going to wait until our CI passed again with the nightly wheels before confirming here. |
Can confirm that the initial test failure caused by #29006 has been fixed by #29041, and our CI is green again after reverting our patch (pyvista/pyvista#7540). Thanks again @seberg. |
Describe the issue:
Hi,
At PyVista, we test against the
numpy
nightly wheels. Our tests recently failed and a patch (pyvista/pyvista#7538) was needed to fix the tests. However, I think this patch should not be needed, and is in fact a regression withnumpy
(i.e. a bug has been introduced).I locally checked out, installed, and tested against recent commits to main and found that the regression is caused by #29006
As mentioned in pyvista/pyvista#7538, our tests usually pass with
But with #29006, we are getting variable results like:
I don't really understand the changes in #29006 or how they might cause this, but from our end the error is generated for a special case where our code creates a temporary object internally to store the array, and it seems the reference to the array is being lost somehow or pre-maturely freed, causing the array values to be corrupted.
The code below fails with commit 0506cf6, but succeeds with c2d5e00 (i.e. the commit immediately preceding). I tried creating a minimal example using only
numpy
, but the references to the array are complex and difficult to reproduce since PyVista wraps a lower-level C++ package (VTK) which also holds its own references to the array data.Reproduce the code example:
Error message:
Python and NumPy Versions:
2.3.0.dev0+git20250519.0506cf6
3.12.2 (v3.12.2:6abddd9f6a, Feb 6 2024, 17:02:06) [Clang 13.0.0 (clang-1300.0.29.30)]
Runtime Environment:
No response
Context for the issue:
This bug seems to cause arrays to be pre-maturely gc'd in some cases, which should probably be avoided. And the root cause has been identified, meaning that the fix can be easily implemented with a simple revert.
The text was updated successfully, but these errors were encountered: