Nick Coghlan <ncogh...@gmail.com> added the comment: While Andreas's patch does indeed prevent the crash, there is something more going on here.
I modified his patch to print out the reference counts immediately after the new INCREF commands. With the INCREF commands commented out, it looks like this: ~/devel/py3k$ ./issue113213.3 START Try import #0 ...Initialising _pickle Pickler type references: 10 Unpickler type references: 8 Module initialised SUCCESS Try import #1 ...Initialising _pickle Pickler type references: 10 Unpickler type references: 8 Module initialised SUCCESS Try import #2 ...Initialising _pickle Pickler type references: 9 Unpickler type references: 7 Module initialised SUCCESS Try import #3 ...Initialising _pickle Pickler type references: 8 Unpickler type references: 6 Module initialised SUCCESS Try import #4 ...Initialising _pickle Pickler type references: 7 Unpickler type references: 5 Module initialised SUCCESS Try import #5 ...Initialising _pickle Pickler type references: 6 Unpickler type references: 4 Module initialised SUCCESS Try import #6 ...Initialising _pickle Pickler type references: 5 Unpickler type references: 3 Module initialised SUCCESS Try import #7 ...Initialising _pickle Pickler type references: 4 Unpickler type references: 2 Module initialised SUCCESS Try import #8 ...Initialising _pickle Pickler type references: 3 Unpickler type references: 1 Module initialised Segmentation fault Note that it does the right thing the first time Py_Finalize is called, but the reference counts start going down after that. When the INCREF is included, the count goes up initially and then levels out. So I believe the simple patch is just masking the problem instead of fixing it. The correct answer is to follow the documentation and implement the module finalisation protocol for _pickle (i.e. move all the static globals into the module struct and implement module traversal and finalisation functions). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11321> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com