|
2011-12-09
| ||
| 00:37 | • Closed ticket [3448556fff]: Segmentation fault on exit in tsv plus 7 other c... artifact: ac225a3f1f user: vasiljevic | |
| 00:07 | • Ticket [3448556fff]: 4 changes artifact: d485b107ae user: tombert | |
|
2011-12-06
| ||
| 21:44 | • Ticket [3448556fff]: 4 changes artifact: 253b7751cd user: vasiljevic | |
| 16:57 | • Ticket [3448556fff]: 4 changes artifact: f229cecfd1 user: tombert | |
| 04:41 | • Ticket [3448556fff]: 4 changes artifact: 62d066d899 user: vasiljevic | |
| 04:35 | • Ticket [3448556fff]: 4 changes artifact: d5b9a4b2f6 user: tombert | |
| 04:26 | • Ticket [3448556fff]: 4 changes artifact: 41c8c4a163 user: tombert | |
| 04:20 | • Ticket [3448556fff]: 4 changes artifact: 57486aeeea user: tombert | |
| 03:56 | • Ticket [3448556fff]: 4 changes artifact: 8d1b833b90 user: mistachkin | |
| 03:43 | • Ticket [3448556fff]: 4 changes artifact: c44cb193d3 user: tombert | |
| 01:00 | • Ticket [3448556fff]: 4 changes artifact: fc7cadf531 user: dgp | |
|
2011-12-05
| ||
| 02:05 | • Ticket [3448556fff]: 4 changes artifact: c629cad7ac user: tombert | |
|
2011-12-02
| ||
| 20:59 | • New ticket [3448556fff]. artifact: f4b1d544c3 user: tombert | |
Segmentation fault on exit in tsv
Closed / Wont Fix3448556fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2011-12-02 20:59:25
Sometimes my Tcl app crashes in between, but I'am somehow able to reproduce crashes (1 out of 5) when doing exit. I was able to trace this down with gdb.
I looks like it is caused by the thread shared variables. Unfort. I havn't been able to create a simple tcl script to reproduce this problem.
My Environment is WinXP, Tcl 8.5.11, Thread 2.7, Compiled with MinGW; Linux I didn't try.
Thx
(gdb) frame 0
#0 0x6220a9e8 in Sp_RecursiveMutexLock (muxPtr=0x6c8)
at ./generic/threadSpCmd.c:1536
1536 if (*muxPtr == (Sp_RecursiveMutex_*)0) {
(gdb) up
#1 0x62206524 in LockArray (interp=0x17baf8e0, array=0x17e4eed0 "host",
flags=0) at ./generic/threadSvCmd.c:728
728 LOCK_BUCKET(bucketPtr); /* Note: no matching unlock below ! */
(gdb)
#2 0x62205d8e in Sv_GetContainer (interp=0x17baf8e0, objc=3,
objv=0x17ba3c1c, retObj=0xd78f0b8, offset=0xd78f0bc, flags=0)
at ./generic/threadSvCmd.c:338
338 arrayPtr = LockArray(interp, array, flags);
(gdb)
#3 0x62207a7f in SvGetObjCmd (arg=0x0, interp=0x17baf8e0, objc=3,
objv=0x17ba3c1c) at ./generic/threadSvCmd.c:1570
1570 ret = Sv_GetContainer(interp, objc, objv, &svObj, &off, 0);
(gdb)
#4 0x64d92aa9 in TclEvalObjvInternal (interp=0x17baf8e0, objc=3,
objv=0x17ba3c1c, command=0xffffffff <Address 0xffffffff out of bounds>,
length=-1, flags=0) at ./../generic/tclBasic.c:3703
3703 code = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, objc, o
bjv);
(gdb)
#5 0x64de4ba5 in TclExecuteByteCode (interp=0x17baf8e0, codePtr=0x17f17ed0)
at ./../generic/tclExecute.c:2416
2416 result = TclEvalObjvInternal(interp, objc, objv,
(gdb)
#6 0x64e3624a in TclObjInterpProcCore (interp=0x17baf8e0,
procNameObj=0x17e64d10, skip=1, errorProc=0x64e3675d <MakeProcError>)
at ./../generic/tclProc.c:1763
1763 result = TclExecuteByteCode(interp, codePtr);
(gdb)
#7 0x64e361bd in TclObjInterpProc (clientData=0x17f129b8, interp=0x17baf8e0,
objc=3, objv=0x17f15b60) at ./../generic/tclProc.c:1653
1653 return TclObjInterpProcCore(interp, objv[0], 1, &MakeProcError);
(gdb)
#8 0x64d92aa9 in TclEvalObjvInternal (interp=0x17baf8e0, objc=3,
objv=0x17f15b60, command=0x0, length=0, flags=131072)
at ./../generic/tclBasic.c:3703
3703 code = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, objc, o
bjv);
(gdb)
#9 0x64d92ffc in Tcl_EvalObjv (interp=0x17baf8e0, objc=3, objv=0x17f15b60,
flags=131072) at ./../generic/tclBasic.c:3901
3901 code = TclEvalObjvInternal(interp, objc, objv, NULL, 0, flags);
(gdb)
#10 0x64d94540 in TclEvalObjEx (interp=0x17baf8e0, objPtr=0x17bb6f38,
flags=131072, invoker=0x0, word=0) at ./../generic/tclBasic.c:5129
5129 result = Tcl_EvalObjv(interp, nelements, elements, flags);
(gdb)
#11 0x64d94414 in Tcl_EvalObjEx (interp=0x17baf8e0, objPtr=0x0, flags=131072)
at ./../generic/tclBasic.c:5054
5054 return TclEvalObjEx(interp, objPtr, flags, NULL, 0);
(gdb)
#12 0x64e48406 in AfterProc (clientData=0x17f258f0)
at ./../generic/tclTimer.c:1145
1145 result = Tcl_EvalObjEx(interp, afterPtr->commandPtr, TCL_EVAL_GLOBAL
);
(gdb)
#13 0x64e47666 in TimerHandlerEventProc (evPtr=0xaaad7b8, flags=-3)
at ./../generic/tclTimer.c:578
578 (*timerHandlerPtr->proc)(timerHandlerPtr->clientData);
(gdb)
#14 0x64e251eb in Tcl_ServiceEvent (flags=-3) at ./../generic/tclNotify.c:675
675 result = (*proc)(evPtr, flags);
(gdb)
#15 0x64e255c7 in Tcl_DoOneEvent (flags=-3) at ./../generic/tclNotify.c:978
978 if (Tcl_ServiceEvent(flags)) {
(gdb)
#16 0x622044a5 in ThreadWait () at ./generic/threadCmd.c:2779
2779 Tcl_DoOneEvent(TCL_ALL_EVENTS);
tombertplain2011-12-05 02:05:34
A bit more on the tcl what I'am doing:
It's a rather simple procedure that calls itself after a random timeout, the first line is accessing the tsv "host" variable which you can see in the segmentation fault. So I've got the feeling that the "after" is called during or after the thread has been destroyed. Hope this helps a bit.
Thx for your support.
proc pingCheckCycle {tid cbObj} {
set newState [isping [tsv::get host [thread::id]]]
if {$newState != [tsv::get pingStatus [thread::id]]} {
tsv::set pingStatus [thread::id] $newState
thread::send -async $tid [list $cbObj callCallback -type onpingcb -map [list %ping $newState]]
}
after [expr {entier(3000 + rand()*3000)}] [list pingCheckCycle $tid $cbObj]
}
dgpplain2011-12-06 01:00:59
The Thread 2.7 branch includes some experimental efforts to attend to finalization matters. You may be demonstrating to use that's a fool's errand. If you can try the same testing using the "trunk" of the Thread package to check whether it's any different, that would be helpful. If it's more convenient, testing release Thread 2.6.7 should be good enough.
tombertplain2011-12-06 03:43:29
Head gives me a compile error, but I will try with 2.6.7 as you suggested. config.status: creating pkgIndex.tcl gcc -DPACKAGE_NAME=\"thread\" -DPACKAGE_TARNAME=\"thread\" -DPACKAGE_VERSION=\"2.7b1\" -DPACKAGE_STRI NG=\"thread\ 2.7b1\" -DPACKAGE_BUGREPORT=\"\" -DBUILD_thread= -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 - DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_IN TTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern -DNO_VIZ= -DTCL_ WIDE_INT_TYPE=long\ long -DHAVE_LSEEK64=1 -DUSE_TCL_STUBS=1 -I"./win" -I"/d/tcltk85/release/include " -pipe -O2 -fomit-frame-pointer -Wall -c `echo ./generic/threadCmd.c` -o threadCmd.o ./generic/threadCmd.c: In function 'ThreadInit': ./generic/threadCmd.c:466:13: error: 'threadHaveInterpCancel' undeclared (first use in this function) ./generic/threadCmd.c:466:13: note: each undeclared identifier is reported only once for each functio n it appears in ./generic/threadCmd.c:471:13: error: 'ThreadCancelObjCmd' undeclared (first use in this function) ./generic/threadCmd.c: In function 'ThreadWait': ./generic/threadCmd.c:2797:9: warning: unused variable 'haveInterpCancel' [-Wunused-variable] make: *** [threadCmd.o] Error 1
mistachkinplain2011-12-06 03:56:29
Thanks for reporting the compile errors. They are now fixed (by check-in [43aa993fb9]).
tombertplain2011-12-06 04:20:09
2.6.7 crashes with two times:
1)
called Tcl_FindHashEntry on deleted table
[Inferior 1 (process 4528) exited with code 03]
2)
#0 CreateHashEntry (tablePtr=0x5ba1a8, key=0x64ea3404 "", newPtr=0x0) at ./../generic/tclHash.c:338
338 if (hash != PTR2UINT(hPtr->hash)) {
(gdb) up
#1 0x64df8baf in FindHashEntry (tablePtr=0x5ba1a8, key=0x64ea3404 "") at ./../generic/tclHash.c:242
242 return CreateHashEntry(tablePtr, key, NULL);
(gdb)
#2 0x64e46f4e in TclpThreadDataKeyGet (keyPtr=0x64ea3404) at ./../generic/tclThreadStorage.c:359
359 Tcl_HashEntry *hPtr = Tcl_FindHashEntry(hashTablePtr, (char *) keyPtr);
(gdb)
#3 0x64e4542f in Tcl_GetThreadData (keyPtr=0x64ea3404, size=8) at ./../generic/tclThread.c:85
85 result = TclpThreadDataKeyGet(keyPtr);
(gdb)
#4 0x64e25ebb in TclFreeObj (objPtr=0x376a140) at ./../generic/tclObj.c:1410
1410 ObjInitDeletionContext(context);
(gdb)
#5 0x64e2386d in NsEnsembleImplementationCmd (clientData=0x37637e8, interp=0x3761d68, objc=4, objv=0x376b010) at ./../g
eneric/tclNamesp.c:6242
6242 Tcl_DecrRefCount(copyObj);
(gdb)
#6 0x64d92aa9 in TclEvalObjvInternal (interp=0x3761d68, objc=4, objv=0x376b010, command=0xffffffff <Address 0xffffffff
out of bounds>, length=-1, flags=0) at ./../generic/tclBasic.c:3703
3703 code = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, objc, objv);
(gdb)
#7 0x64de4ba5 in TclExecuteByteCode (interp=0x3761d68, codePtr=0x3b0a118) at ./../generic/tclExecute.c:2416
2416 result = TclEvalObjvInternal(interp, objc, objv,
(gdb)
#8 0x64e3624a in TclObjInterpProcCore (interp=0x3761d68, procNameObj=0x3a449f0, skip=1, errorProc=0x64e3675d <MakeProcE
rror>) at ./../generic/tclProc.c:1763
1763 result = TclExecuteByteCode(interp, codePtr);
(gdb)
#9 0x64e361bd in TclObjInterpProc (clientData=0x3a5fd18, interp=0x3761d68, objc=7, objv=0x376af30) at ./../generic/tclP
roc.c:1653
1653 return TclObjInterpProcCore(interp, objv[0], 1, &MakeProcError);
(gdb)
#10 0x64d92aa9 in TclEvalObjvInternal (interp=0x3761d68, objc=7, objv=0x376af30, command=0xffffffff <Address 0xffffffff
out of bounds>, length=-1, flags=0) at ./../generic/tclBasic.c:3703
3703 code = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, objc, objv);
(gdb)
#11 0x64de4ba5 in TclExecuteByteCode (interp=0x3761d68, codePtr=0x3aa33b0) at ./../generic/tclExecute.c:2416
2416 result = TclEvalObjvInternal(interp, objc, objv,
(gdb)
#12 0x64de2d81 in TclCompEvalObj (interp=0x3761d68, objPtr=0x376a0f8, invoker=0x0, word=0) at ./../generic/tclExecute.c:
1538
1538 result = TclExecuteByteCode(interp, codePtr);
(gdb)
#13 0x64d947f4 in TclEvalObjEx (interp=0x3761d68, objPtr=0x376a0f8, flags=0, invoker=0x0, word=0) at ./../generic/tclBas
ic.c:5272
5272 result = TclCompEvalObj(interp, objPtr, invoker, word);
(gdb)
#14 0x64d94414 in Tcl_EvalObjEx (interp=0x3761d68, objPtr=0x10, flags=0) at ./../generic/tclBasic.c:5054
5054 return TclEvalObjEx(interp, objPtr, flags, NULL, 0);
tombertplain2011-12-06 04:26:40
2.7 head still crashes: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 6480.0x1a7c] #0 0xfeeefeee in ?? () (gdb) up #1 0x64e46f4e in TclpThreadDataKeyGet (keyPtr=0x64ea3404) at ./../generic/tclThreadStorage.c:359 359 Tcl_HashEntry *hPtr = Tcl_FindHashEntry(hashTablePtr, (char *) keyPtr); (gdb) #2 0x64e4542f in Tcl_GetThreadData (keyPtr=0x64ea3404, size=8) at ./../generic/tclThread.c:85 85 result = TclpThreadDataKeyGet(keyPtr); (gdb) #3 0x64e25ebb in TclFreeObj (objPtr=0x4fa6240) at ./../generic/tclObj.c:1410 1410 ObjInitDeletionContext(context); (gdb) #4 0x64e55a3f in TclArraySet (interp=0x38c35a0, arrayNameObj=0x4f3beb0, arrayElemObj=0x5033128) at ./../generic/tclVar. c:3437 3437 Tcl_DecrRefCount(copyListObj); (gdb) #5 0x64e5528b in Tcl_ArrayObjCmd (dummy=0x0, interp=0x38c35a0, objc=4, objv=0x38b7790) at ./../generic/tclVar.c:3162 3162 return TclArraySet(interp, objv[2], objv[3]); (gdb) #6 0x64d92aa9 in TclEvalObjvInternal (interp=0x38c35a0, objc=4, objv=0x38b7790, command=0xffffffff <Address 0xffffffff out of bounds>, length=-1, flags=0) at ./../generic/tclBasic.c:3703 3703 code = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, objc, objv); (gdb) #7 0x64de4ba5 in TclExecuteByteCode (interp=0x38c35a0, codePtr=0x5070398) at ./../generic/tclExecute.c:2416 2416 result = TclEvalObjvInternal(interp, objc, objv, (gdb) #8 0x64de2d81 in TclCompEvalObj (interp=0x38c35a0, objPtr=0x38cb8d0, invoker=0x0, word=0) at ./../generic/tclExecute.c: 1538 1538 result = TclExecuteByteCode(interp, codePtr); (gdb) #9 0x64d947f4 in TclEvalObjEx (interp=0x38c35a0, objPtr=0x38cb8d0, flags=0, invoker=0x0, word=0) at ./../generic/tclBas ic.c:5272 5272 result = TclCompEvalObj(interp, objPtr, invoker, word); (gdb) #10 0x64d94414 in Tcl_EvalObjEx (interp=0x38c35a0, objPtr=0xfeeefeee, flags=0) at ./../generic/tclBasic.c:5054 5054 return TclEvalObjEx(interp, objPtr, flags, NULL, 0); (gdb) #11 0x710ccd20 in Itcl_EvalMemberCode (interp=0x38c35a0, mfunc=0x506e3c0, member=0x5038138, contextObj=0x5037eb8, objc=9 , objv=0x38b773c) at ./generic/itcl_methods.c:993 993 result = Tcl_EvalObj(interp, mcode->procPtr->bodyPtr); (gdb) #12 0x710cd9b8 in Itcl_ExecMethod (clientData=0x506e3c0, interp=0x38c35a0, objc=9, objv=0x38b773c) at ./generic/itcl_met hods.c:1504 1504 result = Itcl_EvalMemberCode(interp, mfunc, member, contextObj, (gdb) #13 0x710d3559 in Itcl_EvalArgs (interp=0x38c35a0, objc=9, objv=0x38b773c) at ./generic/itcl_util.c:1389 1389 result = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, (gdb) #14 0x710d0062 in Itcl_HandleInstance (clientData=0x5037eb8, interp=0x38c35a0, objc=10, objv=0x38b7738) at ./generic/itc l_objects.c:682 682 result = Itcl_EvalArgs(interp, objc-1, objv+1); (gdb) #15 0x64d92aa9 in TclEvalObjvInternal (interp=0x38c35a0, objc=10, objv=0x38b7738, command=0xffffffff <Address 0xffffffff out of bounds>, length=-1, flags=0) at ./../generic/tclBasic.c:3703 3703 code = (*cmdPtr->objProc)(cmdPtr->objClientData, interp, objc, objv); (gdb) #16 0x64de4ba5 in TclExecuteByteCode (interp=0x38c35a0, codePtr=0x1a843e30) at ./../generic/tclExecute.c:2416 2416 result = TclEvalObjvInternal(interp, objc, objv, (gdb)
tombertplain2011-12-06 04:35:44
Just a question: would a crashing sample be more of help than a backtrace? Because I already tried and failed ... but I could try harder if you like me to. thx
vasiljevicplain2011-12-06 04:41:58
Ideally an Tcl-only script thst illustrates the crash is most valuable.
tombertplain2011-12-06 16:57:51
Are there any differences between Win7 and XP? because yesterday on Win7 I have been able to reproduce the crashes on nearly every attempt. Today working on XP (same binary same source) I'am unable to let it crash. I also tried to write a tcl script resembling my threading architecture but havn't been able to let it crash.
vasiljevicplain2011-12-06 21:44:44
Somebody/something is either trampling over the memory OR there is some race-condition on cleanup/finalization if you regularily exit threads. The latter can be circumvented by never exiting threads (I know it sounds weird). The former may cost lots of resources and hair pulling to find out (as any other memory corruption does). In this case you need to build a minimalistic system that still exposes the error so other people may throw some mem analysers on that. The threading extension is completely platform neutral. If there is a problem there is must hit you on any platfrom and valgrind et.al. should be able to point to the problem...
tombertplain2011-12-09 00:07:15
Well ... good news (depending on the viewpoint) - I have been able to track down the cause ... it consists of two lines: console show package require Pgtcl Then an exit and it crashes. The Pgtcl I'am using is 1.9.0 and I'am going to report this immediately to the developer: https://sourceforge.net/tracker/?func=detail&aid=3454495&group_id=516797&atid=2100300 Thx for your support, sorry for reporting a "wrong" error ... Thomas
vasiljevicplain2011-12-09 00:37:45
allow_comments - 1 OK. Exiting an Tcl shell with any user-threads still active is a bad idea. Because the Tcl library is NOT safe w.r.t. finalisation. If you (or the other package) has created some threads that use Tcl library you need to be sure they are all gone before exiting the main thread (the one that started-up the application). As I see you are able to "kill" the app entirely w/o the Thread extension involved which means there is some memory problem *elsewhere*. This is good for us but bad for you. Well... that's life. I hope you will be able to track this problem and I wish you good luck with that. I am going to close this ticker.
Log in (anonymous is fine) to add a comment.