On Feb 17, 2008 12:29 PM, "Martin v. Löwis" <martin at v.loewis.de> wrote: > Jeffrey Yasskin wrote: > > On Feb 16, 2008 3:12 PM, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote: > >> Should we however intensively search and correct all of them? > >> Is there a clever way to prevent these problems globally, for example > >> by delaying finalizers "just a little"? > > > > A simple way to do this would be to push objects whose refcounts had > > reached 0 onto a list instead of finalizing them immediately, and have > > PyEval_EvalFrameEx periodically swap in a new to-delete list and > > delete the objects on the old one. > > -1. This would only soften the problem in a shallow way. It should still > be possible to create cases where the final cleanup of the object comes > "too early", e.g. when some caller of PyEval_EvalFrameEx still carries > a pointer to some object that got deleted, and then still some code can > get hold of the then-deleted object. It will just be more difficult to > trigger such crashes, depending on the period in which objects are > cleaned. Right. Changing introducing these bugs from "easy" to "possible" sounds like an improvement. Making them harder to trigger has both good and bad effects: they're harder to exploit and harder to reproduce. If we delete on every iteration, it only costs a couple memory accesses more, and should eliminate most of the non-determinism. Anyway, I saw an approach like this work well on a server I used to work on, but there were differences. In particular, there was no way to call a function to trigger deletions; you had to return out to the main loop, which made it a little more reliable than it would be in Python. I suspect it would still fix nearly all of the bugs Amaury is finding since Py_DECREF would no longer return control to the interpreter, but I could be wrong. > The only sane way to never touch deleted objects is to have no > references to them on heap anymore, and to not touch stack references > after the DECREF. > > Regards, > Martin > -- Namasté, Jeffrey Yasskin http://jeffrey.yasskin.info/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4