-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fatal Python error: none_dealloc: deallocating None: bug likely caused by a refcount error in a C extension #137
Comments
@Bltzmn thank you for reporting this. pycvodes uses the "anyode" submodule which has some manual refcounting (which I probably messed up somewhere). You can find the relevant file here: If I search for Py_None in that file, I see that I have tried to construct it with refcounting in mind. Perhaps the destructor Given this issue, I probably shouldn't have done this manually (or have been more careful), and left this to e.g. cython instead, but at the time I wrote it, the cython version was rather slow compared to the hand-rolled code you see there. I don't know if a debug build of CPython perhaps contains asserts to help with deubbing this. It might be worth looking into. Hopefully, I will eventually find the time to hunt this down. But it might be a while (months), but if you or someone else want to try to fix this in the mean time, I'll find the time to review and publish a bugfixed version. Some links to the relevant parts of the CPython API-docs for anyone looking into this:
I notice that the lifetime handling of None has changed in CPython 3.12, so bonus points (for me or anyone else looking into this) for making sure it works on CPython 3.12+ also. |
So I found some time to look into this. I can reproduce your error, and I this is the culprit: I should not be decreasing the reference count there. Adding |
This should be fixed in 0.14.3: Thank you for reporting this! |
Dear Bjodah, Hello! Thanks a lot for usefull software!
I would like to share my problem that I encountered while using the cvode module. If You have the opportunity to give any advice, I will be very grateful.
The problem I'm facing is this: when I do a large number of iterations of integration using, for example,
integrate_predefined
orintegrate_adaptive
methods - the code throws an error:For example, I prepared a simple non-physical example based on Your example with the classic van der Pol oscillator, where we perform the integration operation many times. (For example, when we need to calculate this task locally at different points in space, at different time steps).
Output:
My Ubuntu 22.04 x64 machine with Python 3.9, conda 23.1.0, pycvodes '0.14.1', pyodesys '0.14.2', sundials '6.5.1' returns this deallocating None error after 6824 iterations of this code.
And my another Ubuntu 22.04 x64 machine with Python 3.11, conda 23.7.4, pycvodes '0.14.2', pyodesys '0.14.2', sundials '6.5.1' returns this deallocating None error after 5075 iterations of this code.
But the iteration number in the week itself depends on the task. So, for a chemical kinetics problem, 114800 iterations of integration pass before an error occurs.
I also looked at similar issues that people have linked to, for example: ajakubek/python-llist#11. And I looked at Your cython and C code, but couldn’t find anything resembling these errors in Your code.
If You have the opportunity to give any advice on how to correct the situation, I would be very grateful.
Have a nice time!
The text was updated successfully, but these errors were encountered: