| Ticket UUID: | 02977e0004c72049ed3324fe35f8634bfeede8e6 | ||
| Title: | test oo-1.23 fails | ||
| Type: | Bug | Created on: | 2024-10-22 09:05:08 |
| Submitter: | dkf | Assigned to: | dkf |
| Subsystem: | 35. TclOO Package | Severity: | Important |
| Priority: | 6 | Last modified: | 2024-12-03 12:04:08 |
| Status: | Open | Closed by: | nobody |
| Resolution: | None | Closed on: | |
| Version: | 8.6 | ||
| Description: | ||||
|
Test Note the related | ||||
| User Comments: | ||||
dkf added on 2024-10-27 11:27:51:
OK, the primary problem ( The secondary problem ( dkf added on 2024-11-01 11:52:31:
Turns out that instances of classes currently need to be completely destroyed before the class itself finishes being destroyed. dkf added on 2024-11-01 15:53:25:
Partially fixed. Deep class nesting (a less common case; see jan.nijtmans added on 2024-11-02 20:23:41:
The enable-symbols=mem builds on macOS are failing now, for 8.6, 8.7 and 9.0 See: https://github.com/tcltk/tcl/actions/runs/11640875465/job/32418730320 jan.nijtmans added on 2024-11-03 18:41:55:
I cannot reproduce the problem on macOS Monterey 12.7.6 jan.nijtmans added on 2024-11-05 10:25:57:
The "bug-02977e0004-sebres" branch builds and runs fine on GitHub, on all platforms. @dkf, please review! I don't understand the full implications, but it looks like good work to me! +1 Can we solve the currently broken (macOS) build in all branches (core-8-6-branch, core-8-branch and trunk), one way or another? sebres added on 2024-11-06 13:56:53:
It looks like sporadic issue to me either. Just strange that Donals solution moves it to "stackless" area completely, my variant to almost stackless (allows max depth of 100, hereafter goes to NRE). Anyway both variants must use fewer stack, or there are still more cases entering deep hierarchy. Probably it segfaults on totally different thing (for example by the constellation where object destroy will happen a bit retarded, for instance because decrement with TclOODecrRefCount behaves differently now, if Tcl_DeleteNamespace would not cause direct destroy but do cumulation to the linked list instead). In this case my variant is not a solution, because it simply workarounds that up to 100th level, and it'd then behave similar to Donals solution if the destroy in tests sebres added on 2024-11-06 15:57:42:
Yep, if I switch in my branch the code to retard destroy via NRE immediately (don't bypass first 100 nested calls), I can reproduce the segfault (no idea whether it is the same or not, because compared to Donals solution my branch also does it for classes, not for objects only, so it can be an after-effect of that). The call stack looks like this:
I guess TclOODeleteDescendants does something wrong in case if namespace get deleted, but command is still there (or maybe because the rest of namespace deletion process isn't retarded now, but the objects simply linked to the list). pooryorick added on 2024-11-09 22:35:07:
I can not reproduce this issue on my system. oo-1.23 passes. So does oo-1.24, even without any fix. jan.nijtmans added on 2024-11-12 13:25:52:
> Can we solve the currently broken (macOS) build in all branches (core-8-6-branch, core-8-branch and trunk), one way or another? Since the macOS build is broken for one week already, I took the freedom to undo the change responsible for this. See: [a72e9b170ebd087d] This means, oo-1.23 is a knownBug again. It should fail - again - now, but I didn't verify that. Keeping open. pooryorick added on 2024-11-12 14:56:31:
With commit [53462a5b2932dab2] I still can not reproduced this issue on my Linux kernel 6.11.5 system. oo-1.24 and oo-1.24 both pass. sebres added on 2024-11-12 15:40:03:
> With commit [53462a5b2932dab2] I still can not reproduced this issue on my Linux kernel 6.11.5 system. oo-1.24 and oo-1.24 both pass. It may depend on several factors, like default stack size, build params (e. g. mem-debug), etc... dkf added on 2024-12-02 15:10:11:
I found that Windows seems to default to a relatively small stack size. (Also, you can always just increase the nesting depth; it just adds time to the test.) The difficulty with this bug is getting the destruction order right with classes and instances (because the rug was getting pulled on the class before the instances were fully dead). I spent a week staring at it before giving up and getting at least the simple case working. That's why I marked a test with (Still need to review the proposed fix.) dkf added on 2024-12-03 12:04:08:
Time for some background/thoughts. The full explanationThe 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 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 fixHave 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. | ||||
