tcl core dump

24 views
Skip to first unread message

aotto1968

unread,
Aug 27, 2022, 5:26:57 AMAug 27
to

Hi, the following code is valid tcl

oo::define MkKernelRpcClient method PrivateCreate {cls nme mqHdl} {
my variable selfCash
set selfCash($mqHdl) [namespace eval :: [list $cls create $nme [self] $mqHdl]]
}

oo::define LcConfigRpcClient method LcConfigRpc_create {name } {
my PrivateCreate LcConfigRpc $name [LcConfigRpc Create [self] ]
}
oo::define LcConfigRpcClient export LcConfigRpc_create

and works fine in my test-suite

---- lcconfig-2-2-(0-0-0+binary+pipe+tcl.pipe.pipe) start
++++ lcconfig-2-2-(0-0-0+binary+pipe+tcl.pipe.pipe) PASSED

the test is also simple

test lcconfig-2-2-($F+$B+$C+$S) {cfg as varname} \
-body {
set RET ""
$FH($F) LcConfigRpc_create cfg
cfg ReadString $cfg1
append RET [cfg LookupString {name}]
cfg destroy
set RET
} \
-returnCodes ok \
-result {Books, Movies & More}

and now the BUG

if I skip the "list" and use

oo::define MkKernelRpcClient method PrivateCreate {cls nme mqHdl} {
my variable selfCash
set selfCash($mqHdl) [namespace eval :: [$cls create $nme [self] $mqHdl]]
}

the tcl CORE

==== lcconfig-2-2-(0-0-0+binary+pipe+tcl.pipe.pipe) cfg as varname FAILED
==== Contents of test case:

set RET ""
$FH($F) LcConfigRpc_create cfg
cfg ReadString $cfg1
append RET [cfg LookupString {name}]
cfg destroy
set RET

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0
---- errorInfo: wrong # args: should be "::oo::Obj33::cfg method ?arg ...?"
while executing
"::oo::Obj33::cfg"
(in namespace eval "::" script line 1)
invoked from within
"namespace eval :: [$cls create $nme [self] $mqHdl]"
(class "::MkKernelRpcClient" method "PrivateCreate" line 3)
invoked from within
"my PrivateCreate LcConfigRpc $name [LcConfigRpc Create [self] ]"
(class "::LcConfigRpcClient" method "LcConfigRpc_create" line 2)
invoked from within
"$FH($F) LcConfigRpc_create cfg"
("uplevel" body line 3)
invoked from within
"uplevel 1 $script"
---- errorCode: TCL WRONGARGS
==== lcconfig-2-2-(0-0-0+binary+pipe+tcl.pipe.pipe) FAILED

with the following (only-tcl) backtrace

: BackTrace {
: [ library : filename : lineno ] function
: [ ------- : -------- : ------ ] --------
: [ system : ink/libmkkernel/MkBufferS_mk.h : 682 ] MkDisasterSignal
: [ unknown : unknown : 0 ] unknown
: [ system : tcl-latest/generic/tclOOCall.c : 931 ] IsStillValid
: [ system : tcl-latest/generic/tclOOCall.c : 1013 ] TclOOGetCallContext
: [ system : src/tcl-latest/generic/tclOO.c : 2598 ] TclOOObjectCmdCore
: [ system : src/tcl-latest/generic/tclOO.c : 2460 ] PublicNRObjectCmd
: [ system : /tcl-latest/generic/tclBasic.c : 4458 ] Dispatch
: [ system : /tcl-latest/generic/tclBasic.c : 4494 ] TclNRRunCallbacks
: [ system : /tcl-latest/generic/tclBasic.c : 8191 ] Tcl_NRCallObjProc
: [ system : src/tcl-latest/generic/tclOO.c : 1140 ] ObjectNamespaceDeleted
: [ system : tcl-latest/generic/tclNamesp.c : 939 ] Tcl_DeleteNamespace
: [ system : src/tcl-latest/generic/tclOO.c : 843 ] ObjectRenamedTrace
: [ system : /tcl-latest/generic/tclBasic.c : 3365 ] CallCommandTraces
: [ system : /tcl-latest/generic/tclBasic.c : 3172 ] Tcl_DeleteCommandFromToken
: [ system : tcl-latest/generic/tclNamesp.c : 1146 ] TclTeardownNamespace
: [ system : tcl-latest/generic/tclNamesp.c : 1033 ] Tcl_DeleteNamespace
: [ system : src/tcl-latest/generic/tclOO.c : 843 ] ObjectRenamedTrace
: [ system : /tcl-latest/generic/tclBasic.c : 3365 ] CallCommandTraces
: [ system : /tcl-latest/generic/tclBasic.c : 3172 ] Tcl_DeleteCommandFromToken
: [ tclmsgque : LibMkKernel_tcl.c : 1334 ] tcl_mkkernel_AtomDeleteHard
: [ tclmsgque : MkObjectC_tcl.c : 634 ] tcl_mkkernel_MkObjectC_Delete
: [ system : tcl-latest/generic/tclOOCall.c : 313 ] TclOOInvokeContext
: [ system : src/tcl-latest/generic/tclOO.c : 2644 ] TclOOObjectCmdCore
: [ system : src/tcl-latest/generic/tclOO.c : 2460 ] PublicNRObjectCmd
: [ system : /tcl-latest/generic/tclBasic.c : 4458 ] Dispatch
: [ system : /tcl-latest/generic/tclBasic.c : 4494 ] TclNRRunCallbacks
: [ system : /tcl-latest/generic/tclBasic.c : 4217 ] Tcl_EvalObjv
: [ system : /tcl-latest/generic/tclBasic.c : 5363 ] TclEvalEx
: [ system : tcl-latest/generic/tclIOUtil.c : 1824 ] Tcl_FSEvalFileEx
: [ system : c/tcl-latest/generic/tclMain.c : 403 ] Tcl_MainEx
: [ system : c/tcl-latest/unix/tclAppInit.c : 84 ] main
: [ unknown : unknown : 0 ] unknown
: [ unknown : unknown : 0 ] unknown
: [ system : ../sysdeps/x86_64/start.S : 115 ] unknown
: [ unknown : unknown : 0 ] unknown
: }
../Nhi1Exec: line 671: 71732 Aborted LD_PRELOAD='/usr/lib64/gcc/x86_64-suse-linux/11/libasan.so ' .../tclsh8.6
'.../lcconfig.test' '--dev-testing' '--lng-tcl' '--block-2' '-match' 'lcconfig-2-2-*'

1. The "Nhi1Exec" tool is just the starter for test case, on or case add the libasan.so library for mem-check
2. The "Backtrace" feature is my own function just to react on unix signal SIGSEGV and write a backtrace

void MkDisasterSetup(void) {
// once per application
static bool setup_done = false;
if (setup_done) return;
setup_done = true;

// initialised to all zero (I vote for GCC style breach of standard here)
struct sigaction sa = {};

sa.sa_handler = MkDisasterSignal;
sa.sa_flags = 0 /* | SA_RESETHAND | SA_NODEFER */; /* To have or have not */
sigaction(SIGSEGV, &sa, NULL);
}

ANALYSES: as you see mainly TCL code is involved,

1. "$cls create ..." create a VALID oo-object (but not in the :: NS because the "list" is missing
2. "namespace eval :: OBJ" write an error because call the new "oo-object" without arg is invalid
3. PROBLEM: "something" is calling the destructor of the new object

313 from TclOOInvokeContext

/*
* Run the method implementation.
*/

return mPtr->typePtr->callProc(mPtr->clientData, interp, <------ PROBLEM
(Tcl_ObjectContext) contextPtr, objc, objv);
}


CRASH: it seems the oPtr->selfCls is brokern

static inline int
IsStillValid(
CallChain *callPtr,
Object *oPtr,
int flags,
int mask)
{
if ((oPtr->flags & USE_CLASS_CACHE)) {
oPtr = oPtr->selfCls->thisPtr; <------ CRASH
flags |= USE_CLASS_CACHE;
}
return ((callPtr->objectCreationEpoch == oPtr->creationEpoch)
&& (callPtr->epoch == oPtr->fPtr->epoch)
&& (callPtr->objectEpoch == oPtr->epoch)
&& ((callPtr->flags & mask) == (flags & mask)));
}

mfg

Reply all
Reply to author
Forward
0 new messages