| Ticket UUID: | 7842f33a5cc5eed080a57f8af9ac1e7e3cee444a | ||
| Title: | TCL crash (core) | ||
| Type: | Bug | Created on: | 2022-08-27 21:39:42 |
| Submitter: | anonymous | Assigned to: | dkf |
| Subsystem: | 35. TclOO Package | Severity: | Critical |
| Priority: | 9 Immediate | Last modified: | 2024-05-23 10:33:40 |
| Status: | Closed | Closed by: | dkf |
| Resolution: | Fixed | Closed on: | 2024-05-23 10:33:40 |
| Version: | 8.6 | ||
| Description: | ||||
The following script will CRASH tcl
TWO instances are linked together, the second instance uses in the destructor the first instance. but the second instance is created in the namespace of the first instance. if the first instance is deleted the destructor of the second instance is called and this is calling the first instance again etc…
oo::class create RpcClient {
}
oo::define RpcClient method write {name } {
puts "RpcClient → $name"
}
oo::class create LcConfigRpcClient {
superclass RpcClient
}
oo::define LcConfigRpcClient method LcConfigRpc_create_bug {name } {
LcConfigRpc create $name [self] 111
}
oo::define LcConfigRpcClient export LcConfigRpc_create_bug
oo::class create MkObjectRpc {
variable hdl
}
oo::define MkObjectRpc constructor {rpcHdl mqHdl} {
set hdl $mqHdl
oo::objdefine [self] forward rpc $rpcHdl
}
oo::define MkObjectRpc destructor {
my rpc write otto-$hdl
}
oo::class create LcConfigRpc {
superclass MkObjectRpc
variable hdl
}
set FH [LcConfigRpcClient new]
$FH LcConfigRpc_create_bug cfg
$FH destroy
| ||||
| User Comments: | ||||
chrstphrchvz added on 2023-07-08 12:23:33:
Changing subsystem to TclOO; the “Objects” subsystem is meant for Tcl values in general. chrstphrchvz added on 2023-10-22 16:41:58:
The reporter’s example still crashes for core-8-6-branch. UBSan (-fsanitize=null) and ASan (-fsanitize=address) errors: A NULL+0xf0 dereference at tclOOCall.c:1024 would mean that oPtr->selfCls is NULL.tcl/generic/tclOOCall.c:1024:25: runtime error: member access within null pointer of type 'struct Class' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior tcl/generic/tclOOCall.c:1024:25 in AddressSanitizer:DEADLYSIGNAL ================================================================= ==65360==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000000f0 (pc 0x0001109f36a5 bp 0x7ff7b1f52830 sp 0x7ff7b1f51c80 T0) ==65360==The signal is caused by a READ memory access. ==65360==Hint: address points to the zero page. #0 0x1109f36a5 in TclOOGetCallContext tclOOCall.c:1024 #1 0x1109be8b2 in TclOOObjectCmdCore tclOO.c:2599 #2 0x1109cd36d in PublicNRObjectCmd tclOO.c:2461 #3 0x10fa83837 in Dispatch tclBasic.c:4520 #4 0x10fa63bbf in TclNRRunCallbacks tclBasic.c:4556 #5 0x10fa52ad3 in Tcl_NRCallObjProc tclBasic.c:8269 #6 0x1109c8db5 in ObjectNamespaceDeleted tclOO.c:1141 #7 0x1106b22dd in Tcl_DeleteNamespace tclNamesp.c:917 #8 0x1109cd534 in ObjectRenamedTrace tclOO.c:844 #9 0x10fa57e58 in CallCommandTraces tclBasic.c:3426 #10 0x10fa4d7e7 in Tcl_DeleteCommandFromToken tclBasic.c:3226 #11 0x1106ba16e in TclTeardownNamespace tclNamesp.c:1124 #12 0x1106b3857 in Tcl_DeleteNamespace tclNamesp.c:1011 #13 0x1109cd534 in ObjectRenamedTrace tclOO.c:844 #14 0x10fa57e58 in CallCommandTraces tclBasic.c:3426 #15 0x10fa4d7e7 in Tcl_DeleteCommandFromToken tclBasic.c:3226 #16 0x1109d4b98 in TclOO_Object_Destroy tclOOBasic.c:361 #17 0x1109eb8c0 in TclOOInvokeContext tclOOCall.c:314 #18 0x1109c0400 in TclOOObjectCmdCore tclOO.c:2645 #19 0x1109cd36d in PublicNRObjectCmd tclOO.c:2461 #20 0x10fa83837 in Dispatch tclBasic.c:4520 #21 0x10fa63bbf in TclNRRunCallbacks tclBasic.c:4556 #22 0x10fa76fdf in TclEvalObjEx tclBasic.c:6138 #23 0x10fa5f951 in Tcl_EvalObjEx tclBasic.c:6119 #24 0x110510fa2 in Tcl_RecordAndEvalObj tclHistory.c:191 #25 0x1106ab031 in Tcl_MainEx tclMain.c:520 #26 0x10dfab8d6 in main tclAppInit.c:91 #27 0x11a14552d in start+0x1cd (dyld:x86_64+0x552d) dkf added on 2024-05-20 13:36:40:
Stripped down further (from a test case I'm developing):
Have confirmed that this is a current issue in both 8.6 and trunk. dkf added on 2024-05-20 13:51:11:
Debug-annotated stack trace
dkf added on 2024-05-20 15:16:02:
The problem was in the computation of stereotypical call chains when the object in question had already gone rather a long way through the destruction process. Nasty! Things no longer crash, but if you want to get the jan.nijtmans added on 2024-05-20 20:53:00:
---- oo-35.7.1 start Test file error: child killed: segmentation violation Something is still wrong jan.nijtmans added on 2024-05-21 08:37:38:
The 8.6 build succeeded, the 8.7 build failed on all platforms. @dkf please have a look. oehhar added on 2024-05-21 12:35:06:
Magic Sergey has fixed the crash reported below by commit [1d16344c8c]. Thank you all, great team, Harald apnadkarni added on 2024-05-22 03:40:33:
While the crash may be fixed, it is not clear to me how things get into that state and if there is an underlying fault in the call chain computation that is hidden. Still worth Donal also taking a look imo. sebres added on 2024-05-22 10:53:03:
Well, the case where The fact that it fails in 8.7+ but not in 8.6 is easy to explain: in 8.6 since [b0e486eaa693a6a6] Now this is fixed everywhere (I also restored the mentioned check in [22966032c2912825]), additionally the invocation of apnadkarni added on 2024-05-22 13:42:06:
Thanks for the explanation Sergey. dkf added on 2024-05-23 10:33:40:
Thanks for fixing that. | ||||
