Tcl Source Code

View Ticket
Login
Ticket UUID: 994748
Title: Tcl_RegisterChannel: duplicate channel names
Type: Bug Created on: 2004-07-20 19:25:05
Submitter: mistachkin Assigned to: andreas_kupries
Subsystem: 25. Channel System Severity:
Priority: 7 High Last modified: 2026-10-12 13:54:02
Status: Pending Closed by: andreas_kupries
Resolution: Works For Me Closed on: 2005-10-05 22:59:05
Version: obsolete: 8.4.6
Description:
After running TkChat for a long time, the panic
"Tcl_RegisterChannel: duplicate channel names" is seen
upon exiting.  This bug seems to exist in HEAD and
core-8-4-branch.  Here is the stack trace:

NTDLL! DbgBreakPoint address 0x77f7645c
TCL84! Tcl_PanicVA + 201 bytes
TCL84! Tcl_Panic + 31 bytes
TCL84! Tcl_RegisterChannel + 122 bytes
TCL84! Tcl_SocketObjCmd + 1071 bytes
TCL84! TclEvalObjvInternal + 778 bytes
TCL84! Tcl_EvalEx + 577 bytes
TCL84! Tcl_EvalObjEx + 200 bytes
TCL84! Tcl_EvalObjCmd + 123 bytes
TCL84! TclEvalObjvInternal + 778 bytes
TCL84! TclCompEvalObj + 4284 bytes
TCL84! TclCompEvalObj + 405 bytes
TCL84! TclObjInterpProc + 1259 bytes
TCL84! TclEvalObjvInternal + 778 bytes
TCL84! TclCompEvalObj + 4284 bytes
TCL84! TclCompEvalObj + 405 bytes
TCL84! TclObjInterpProc + 1259 bytes
TCL84! TclEvalObjvInternal + 778 bytes
TCL84! TclCompEvalObj + 4284 bytes
TCL84! TclCompEvalObj + 405 bytes
TCL84! TclObjInterpProc + 1259 bytes
TCL84! TclEvalObjvInternal + 778 bytes
TCL84! Tcl_EvalEx + 577 bytes
TCL84! Tcl_Eval + 23 bytes
TCL84! Tcl_GlobalEval + 44 bytes
TK84! Tk_BindEvent + 2510 bytes
TK84! TkBindEventProc + 405 bytes
TK84! Tk_HandleEvent + 1747 bytes
TK84! Tk_DestroyWindow + 762 bytes
TK84! Tk_DestroyWindow + 513 bytes
TK84! Tk_DestroyWindow + 513 bytes
TK84! Tk_GetNumMainWindows + 279 bytes
TCL84! Tcl_Finalize + 105 bytes
TCL84! Tcl_Exit + 8 bytes
TCL84! Tcl_ExitObjCmd + 104 bytes
TCL84! TclEvalObjvInternal + 778 bytes
TCL84! TclCompEvalObj + 4284 bytes
TCL84! TclCompEvalObj + 405 bytes
TCL84! TclObjInterpProc + 1259 bytes
TCL84! TclEvalObjvInternal + 778 bytes
TCL84! Tcl_EvalEx + 577 bytes
TCL84! Tcl_Eval + 23 bytes
TCL84! Tcl_GlobalEval + 44 bytes
TK84! TkWmProtocolEventProc + 174 bytes
TK84! Tk_HandleEvent + 1431 bytes
TK84! TkQueueEventForAllChildren + 216 bytes
TCL84! Tcl_ServiceEvent + 138 bytes
TCL84! Tcl_DoOneEvent + 425 bytes
TK84! Tk_MainLoop + 25 bytes
TK84! Tk_MainEx + 1305 bytes
WISH84! 004010ab()
WISH84! 004015be()
User Comments:
andreas_kupries added on 2004-10-29 02:38:06:
Logged In: YES 
user_id=75003

Could it be that the generator for channel names wrapped
around ?  I.e could it be that socket created a new channel,
and the name it created for it was the name of an existing
channel which had not been closed ? This would also imply
that tkchat is leaking socket channel handles. 

Looking deeper at the stack - It seems that some code tries
to _create_ a new socket while the core is in the
finalization (exit -> finalization -> destroy window ->
event -> event handler = eval -> .... -> socket -> boom).

Were you able to reproduce this, with a stack telling us
more about the program state ?

How long had you let tkchat run to get this ?

andreas_kupries added on 2005-10-06 05:59:05:
Logged In: YES 
user_id=75003

Is this still reproducible with the current heads of 8.4 and
main branch ?

mistachkin added on 2005-10-10 02:34:07:
Logged In: YES 
user_id=113501


I believe that this bug still exists in at least 8.4 and
possibly HEAD.  TkChat was changed to use Jabber, so I'm not
sure if you can repro this bug using TkChat any more;
however, I do not believe that this bug was ever "fixed".  I
think that some of the other IO finalization bugs may be
related.

serhiy.storchaka added on 2026-10-12 13:54:02:

I cannot reproduce this with 8.6.18 and 9.1 on Windows and Linux: a script which leaves 300 sockets open and creates 300 more from a <Destroy> binding of . during exit exits cleanly. Socket channel names are now derived from the address of the channel state, so a new socket cannot get the name of a channel that is still registered.