-
Notifications
You must be signed in to change notification settings - Fork 48
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: deallocating None #11
Comments
This issue seems to be correlated with #10. The Instead |
When a list or any of its nodes references itself in a way that creates a cycle, their PyObjects may be visited multiple times during deallocation of the list. To handle this case cleanly, Python documentation recommends to release references held by such PyObject with Py_CLEAR. The macro works similarly to Py_XDECREF, but also sets the reference to NULL, which prevents repeated deallocation of the reference during subsequent visits of its owner PyObject. Most of the references held by llist PyObjects are released by Py_CLEAR. One of the exceptions was Py_None, which is a global variable that may not be set to NULL. To work around this limitation, llist module simply invoked Py_DECREF on Py_None during each visit of a garbage collected PyObject. Unfortunately this could release Py_None too many times, effectively 'stealing' references from other objects and eventually leading to a crash. To fix this issue, each linked list and node which holds a Py_None reference will now set a flag in its PyObject structure. The first release of the Py_None reference will clear the flag to prevent future traversal of this object from repeating the operation. Closes issue #11.
Fixed in |
I have a complex application which parsers hundreds of files and for each line on each the file, create a
dllistnode
by subclassing it. The following code is what I do, but millions of times:-->
After running my application, in a full database, I got the following error out of nowhere:
This is not related to the actual file being parsed because when running the application only with the lastest file running, everything works fine, i.e., no errors.
Searching on Google for this error
Fatal Python error: deallocating None
I found this threads:I ran gdb, but not stack trace was created. Then, I cloned this repository and removed all 4 lines which called
Py_DECREF(Py_None)
. The following is a git diff of the changed files:Then, I reinstalled
llist
withpip3 install -v .
and ran my application and the errorFatal Python error: deallocating None
was fixed.Now:
Py_None
objects?Py_DECREF(Py_None)
be removed from the code?Looking at the issue: #7 Memory leak when cycle reference to dllistnode
I could find this code: 26bb440 Support for cyclic garbage collection
Where you moved/played around changing the lines
Py_DECREF(Py_None)
from here to there.The text was updated successfully, but these errors were encountered: