Movatterモバイル変換
[0]ホーム
[Python-Dev] Crash in new "trashcan" mechanism.
Christian Tismertismer@tismer.com
Tue, 11 Apr 2000 18:57:09 +0200
Vladimir Marangozov wrote:>> Christian Tismer wrote:> >> > About extensions and Trashcan.> > ...> > Or, I made a mistake in this little code:> Maybe unrelated, but this code does not handle the case when> PyList_Append fails. If it fails, the object needs to be deallocated> as usual. Looking at the macros, I don't see how you can do that> because Py_TRASHCAN_SAFE_END, which calls the above function,> occurs after the finalization code...Yes, it does not handle this case for the following reasons:Reason 1)If the append does not work, then the system is apparentlyin a incredibly bad state, most probably broken!Note that these actions only take place when we have arecursion depth of 50 or so. That means, we already freedsome memory, and now we have trouble with this probablylittle list. I won't touch a broken memory management.Reason 2)If the append does not work, then we are not allowed todeallocate the element at all. Trashcan was written inorder to avoid crashes for too deeply nested objects.The current nesting level of 20 or 50 is of coursevery low, but generally I would assume that the limitis choosen for good reasons, and any deeper recursionmight cause a machine crash. Under this assumption,the only thing you can do is to forget about the object.Remark ad 1):I had once changed the strategy to use a tuple construct instead.Thinking of memory problems when the shredder list must begrown, this could give an advantage. The optimum would beif the destructor data structure is never bigger than thesmallest nested object. This would even allow me to recyclethese for the destruction, without any malloc at all.ciao - chris-- Christian Tismer :^) <mailto:tismer@appliedbiometrics.com>Applied Biometrics GmbH : Have a break! Take a ride on Python'sKaunstr. 26 : *Starship*http://starship.python.net14163 Berlin : PGP key ->http://wwwkeys.pgp.netPGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today?http://www.stackless.com
[8]ページ先頭