Overview
| Artifact ID: | 7ca938e6c91f5a440fa97e7ca603a02185ea47751b516c288dfa1ec758d235de |
|---|---|
| Ticket: | 02977e0004c72049ed3324fe35f8634bfeede8e6
test oo-1.23 fails |
| User & Date: | dkf on 2024-12-03 12:04:08 |
Changes
- icomment:
Time for some background/thoughts. ## The full explanation The problem is that when destroying an object or class, its namespace is destroyed (this is the central entity of every TclOO object) and that in turn triggers the destruction of every command within the namespace (which can include other objects). Classes have the additional complexity that they also destroy every downstream entity (i.e., their instances and subclasses). This recursive destruction can blow out the C stack; the depth required to do this is variable, depending on the activation record sizes, stack size, etc. and if you don't hit the stack limit then what we have in 8.6.15 works absolutely fine. But stack sizes are not infinite, and it's always possible to find a level at which any system will fail; the particular values I picked worked on this system, but I make no claim of universality unlike with the general form of the problem. I'd rather not increase things to 100 million nested objects, as that will just make for a horribly slow set of tests. The usual fix for this sort of thing (i.e., what is used in `Tcl_Obj`s deletion system, which faced a similar problem) is to maintain a queue of entities for destruction, and any attempt to destroy an entity while destruction is ongoing just results in the item being queued (the top level destruction processes that queue). This works great for nested objects, but *doesn't for classes*; the instances of the class *must* be destroyed before the class goes otherwise the running of the destructors goes absolutely haywire. (I was very annoyed when I worked out what was going wrong there.) In general, **the order of destruction is a very sensitive thing**; we really don't want to change that because that's very observable by user scripts (and things like TDBC rely on it a lot). ## Suggested form of fix Have a queue of destruction, but when the object being destroyed is a class that still has active dependent entities, instead of it being destroyed it should instead be re-queued for later processing. I'm not at all sure that the place where I processed the destruction queue is the correct one.
- login: "dkf"
- mimetype: "text/x-markdown"