|
2024-12-03
| ||
| 12:04 | • Ticket [02977e0004] test oo-1.23 fails status still Open with 3 other change... artifact: 7ca938e6c9 user: dkf | |
|
2024-12-02
| ||
| 15:10 | • Ticket [02977e0004]: 3 changes artifact: 9f716dae54 user: dkf | |
|
2024-11-21
| ||
| 13:39 | • Closed ticket [3422267ed6]: segmentation fault from deleting the the target of a... artifact: f017e40e3d user: jan.nijtmans | |
|
2024-11-12
| ||
| 15:40 | • Ticket [02977e0004] test oo-1.23 fails status still Open with 3 other change... artifact: 6d337a3287 user: sebres | |
| 14:56 | • Ticket [02977e0004]: 3 changes artifact: c086a7b047 user: pooryorick | |
| 13:25 | • Ticket [02977e0004]: 3 changes artifact: bdbab17a96 user: jan.nijtmans | |
| 13:03 | backout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. check-in: a72e9b170e user: jan.nijtmans tags: core-8-6-branch | |
| 12:10 | backout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. Remove some unneeded typeca... check-in: e1e7f93e74 user: jan.nijtmans tags: core-8-branch | |
| 09:41 | backout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. check-in: 53462a5b29 user: jan.nijtmans tags: trunk, main | |
|
2024-11-10
| ||
| 22:48 | backout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. closed check-in: 1008c8506a user: jan.nijtmans tags: bug-02977e0004 | |
|
2024-11-09
| ||
| 22:35 | • Ticket [02977e0004] test oo-1.23 fails status still Open with 3 other change... artifact: bf2b583e92 user: pooryorick | |
|
2024-11-06
| ||
| 15:57 | • Ticket [02977e0004]: 3 changes artifact: 138884f44b user: sebres | |
| 13:56 | • Ticket [02977e0004]: 3 changes artifact: 94f895e1c8 user: sebres | |
|
2024-11-05
| ||
| 10:25 | • Ticket [02977e0004]: 3 changes artifact: 46b3d9c2bb user: jan.nijtmans | |
|
2024-11-03
| ||
| 18:41 | • Ticket [02977e0004]: 3 changes artifact: 8fe527a0f0 user: jan.nijtmans | |
|
2024-11-02
| ||
| 20:23 | • Ticket [02977e0004]: 3 changes artifact: f4f9c828e3 user: jan.nijtmans | |
|
2024-11-01
| ||
| 19:32 | another variant to fix [02977e0004] (inclusive class deletion) using NRE-callout, without to extend ... check-in: 8d462098e4 user: sebres tags: bug-02977e0004-sebres | |
| 15:53 | • Ticket [02977e0004] test oo-1.23 fails status still Open with 4 other change... artifact: aad711754f user: dkf | |
| 15:51 | [02977e0004] Reduce impact of recursion depth bug. check-in: b569739692 user: dkf tags: core-8-6-branch | |
| 11:52 | • Ticket [02977e0004] test oo-1.23 fails status still Open with 3 other change... artifact: 7e15f630f7 user: dkf | |
|
2024-10-27
| ||
| 11:27 | • Ticket [02977e0004]: 4 changes artifact: 7f5a5ce470 user: dkf | |
|
2024-10-26
| ||
| 19:57 | Trying to fix [02977e0004], but causes other problems. check-in: 2874bf0d6b user: dkf tags: bug-02977e0004 | |
|
2024-10-22
| ||
| 09:05 | • Ticket [02977e0004] test oo-1.23 fails status still Open with 3 other change... artifact: 8905337dcc user: dkf | |
| 09:05 | • Ticket [02977e0004]: 3 changes artifact: 1fc986f60b user: dkf | |
| 09:05 | • New ticket [02977e0004]. artifact: 772116dacf user: dkf | |
test oo-1.23 fails
Test oo-1.23 fails, and is hard to fix because the order of destruction of the insides of an object is sensitive. Tests oo-0.2 and oo-12.8 seem to act as canaries for getting it wrong (but that's just from experimenting with trying to fix this bug).
Note the related oo-1.22 which checks destruction order.
f017e40e3dClosed ticket [3422267ed6]: segmentation fault from deleting the the target of an imported alias during a trace on the target of the alias plus 6 other changes ticket2024-11-21 13:39:28a72e9b170ebackout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. check-in2024-11-12 13:03:53e1e7f93e74backout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. Remove some unneeded typecasts. Some int -> Tcl_Size check-in2024-11-12 12:10:4053462a5b29backout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. check-in2024-11-12 09:41:251008c8506abackout [b569739692]: [02977e0004] Reduce impact of recursion depth bug. check-in2024-11-10 22:48:428d462098e4another variant to fix [02977e0004] (inclusive class deletion) using NRE-callout, without to extend Object structure check-in2024-11-01 19:32:04b569739692[02977e0004] Reduce impact of recursion depth bug. check-in2024-11-01 15:51:412874bf0d6bTrying to fix [02977e0004], but causes other problems. check-in2024-10-26 19:57:26
OK, the primary problem (oo-1.23) is that the teardown process of an object can trigger the teardown process of other objects recursively, and you can string this together arbitrarily deep.
The secondary problem (oo-12.8 and others) is that a class's instances must complete their teardown (at least as far as running the destructor) before the class is destroyed. This makes simple queueing of calls to Tcl_DeleteNamespace() not be enough.
Turns out that instances of classes currently need to be completely destroyed before the class itself finishes being destroyed.
Partially fixed. Deep class nesting (a less common case; see oo-1.24) still not right.
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
I cannot reproduce the problem on macOS Monterey 12.7.6
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?
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 test-oo-1.18* would happen also after 100th level.
With other words I'm pretty sure, it'd fail if one'd rewrite 100 to 0 (e. g. always add to NRE) in d53e9b86c261a0d9&ln=873-887, because would also firstly cumulate it to linked list and destroy at top level with first object.
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:
Thread 1 received signal SIGSEGV, Segmentation fault.
Tcl_DeleteCommandFromToken (interp=0x320dbd0, cmd=0x32d4500) at generic/tclBasic.c:3203
3203 cmdPtr->nsPtr->refCount++;
(gdb) where
#0 Tcl_DeleteCommandFromToken (interp=0x320dbd0, cmd=0x32d4500) at generic/tclBasic.c:3203
#1 0x00007ffd515fcaad in TclOODeleteDescendants (interp=0x320dbd0, oPtr=0x32bcf70) at generic/tclOO.c:953
#2 0x00007ffd515fd26d in ObjectNamespaceDeleted (clientData=0x32bcf70) at generic/tclOO.c:1168
#3 0x00007ffd515f4841 in Tcl_DeleteNamespace (namespacePtr=0x32bd080) at generic/tclNamesp.c:918
#4 0x00007ffd515f4ed6 in TclTeardownNamespace (nsPtr=0x32b9370) at generic/tclNamesp.c:1196
#5 0x00007ffd515f4a47 in Tcl_DeleteNamespace (namespacePtr=0x32b9370) at generic/tclNamesp.c:1012
#6 0x00007ffd515f4ed6 in TclTeardownNamespace (nsPtr=0x2b08070) at generic/tclNamesp.c:1196
#7 0x00007ffd514cb700 in DeleteInterpProc (blockPtr=0x320dbd0 " Y \003") at generic/tclBasic.c:1506
#8 0x00007ffd51626410 in Tcl_EventuallyFree (clientData=0x320dbd0, freeProc=0x7ffd514cb50d <DeleteInterpProc>) at generic/tclPreserve.c:296
#9 0x00007ffd514cb504 in Tcl_DeleteInterp (interp=0x320dbd0) at generic/tclBasic.c:1394
#10 0x00007ffd515c6594 in ChildObjCmdDeleteProc (clientData=0x320dbd0) at generic/tclInterp.c:2684
#11 0x00007ffd514cddf1 in Tcl_DeleteCommandFromToken (interp=0x788260, cmd=0x32e55d0) at generic/tclBasic.c:3276
#12 0x00007ffd515c2ee6 in NRInterpCmd (clientData=0x0, interp=0x788260, objc=3, objv=0x600e80) at generic/tclInterp.c:852
#13 0x00007ffd514cfad0 in Dispatch (data=0x333ef68, interp=0x788260, result=0) at generic/tclBasic.c:4505
#14 0x00007ffd514cfb65 in TclNRRunCallbacks (interp=0x788260, result=0, rootPtr=0x0) at generic/tclBasic.c:4541
#15 0x00007ffd514cf39a in Tcl_EvalObjv (interp=0x788260, objc=5, objv=0x600390, flags=2097168) at generic/tclBasic.c:4260
#16 0x00007ffd514d18fc in TclEvalEx (interp=0x788260, script=0x2a390c0 "# This file contains a collection of tests for Tcl's built-in object system.\n# Sourcing this file into Tcl runs the tests and generates output for errors.\n# No output means no errors were found.\n#\n# C"..., numBytes=125476, flags=0, line=54, clNextOuter=0x0, outerScript=0x2a390c0 "# This file contains a collection of tests"...) at generic/tclBasic.c:5409
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).
I can not reproduce this issue on my system. oo-1.23 passes. So does oo-1.24, even without any fix.
> 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.
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.
> 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...
I get it reproduced pretty simple with --enable-symbols=mem and stack-size reduced to 4MB:
(by 8MB it is sporadic either, larger than 16MB is almost not reproducible)
$ uname -mrs
Linux 6.9.7+bpo-amd64 x86_64
$ mkdir unix/Debug_mem; cd $_
$ ../configure --enable-symbols=mem
$ ulimit -s 4096; make test TESTFLAGS='-constraint knownBug -file oo.test -match oo-1.2[34] -verbose step -singleproc 1'
...
oo.test
---- oo-1.23 start
Segmentation fault
make: *** [Makefile:921: test-tcl] Error 139
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 knownBug...
(Still need to review the proposed fix.)
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_Objs 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.