Skip to content
Tcl Source Code Artifact [a2de3f8a55]
Login

Artifact [a2de3f8a55]

Artifact a2de3f8a5570edc5140511ed834ec6efa171d440:

Ticket change [a2de3f8a55] - New ticket [1225727fffffffff|1225727fff] <i>crash when process exits with open pipes</i>. by kennykb on 2005-06-22 18:46:17.
D 2005-06-22T18:46:17
J assignee kennykb
J cmimetype text/plain
J comment tclWinPipe.c\scleans\sup\sits\sprocess\slist\sin\san\nexit\shandler\screated\sby\sTcl_CreateExitHandler.\nThe\sproblem\swith\sthis\sis\sthat\sthe\sexit\shandler\sis\ncalled\stoo\ssoon\s-\swith\sthe\spipe\sstill\sopen.\nWhen,\ssubsequently,\sTcl_FinalizeIOSubsystem\ncloses\sthe\spipe,\sthe\scode\sgoes\soff\sto\nTclCleanupChildren\sto\scollect\sthe\sexit\sstatus\nand\sreap\sthe\schild\sprocesses.\s\sThat\sprocedure\neventually\sgets\sinto\sTcl_WaitPid,\swhich\scalls\nPipeInit.\s\sPipeInit\ssees\sthat\s'initialized'\sis\sfalse,\nand\swinds\sup\scalling\sTcl_CreateExitHandler\sto\nre-establish\sthe\sexit\shandler.\n\nThe\smemory\sused\sby\sthe\ssecond\sexit\shandler\nis\strashed\supon\sreturn\sto\sTcl_Finalize\sby\sthe\ncalls\sto\sTcl_FinalizeMemorySubsystem\sand\nTcl_FinalizeThreadAlloc.\s\sThe\sexit\shandler\spointer,\nhowever,\sis\sstill\slinked\son\sthe\schain.\sOnce\sthe\nprocess\sfinally\sexits,\sthere\sis\sanother\scall\sto\nTcl_Finalize\sfrom\stclWin32Dll.c\s(DllMain).\nThis\scall\sruns\sProcExitHandler\sagain\s(which\nis\sinnocuous;\sall\sit\sdoes\sis\sturn\soff\sthe\n'initialized'\sflag).\sThen\sTcl_Finalize\sdoes\nckfree\son\sthe\sexit\shandler\sstructure,\swhich\nwas\strashed\sin\sTcl_FinalizeMemorySubsystem,\ncorrupting\sthe\sheap.\n\nIt\sturns\sout\sthat\sthis,\stoo,\sis\s*usually*\sinnocuous,\nbecause\slittle\sallocated\smemory\sremains\nthis\slate\sin\sthe\sprocess.\s\sI\shave\sseen,\showever,\nthe\s'ckfree'\scorrupt\sthe\slock\stable\sin\smsvcrtd.dll,\nresulting\sin\sa\scrash\sdeep\sin\sntdll.dll\son\sthe\nfinal\scleanup\sof\sC\sruntime.\n\nThe\sattached\spatch\sis\san\sattempt\sto\sfix\sit\nin\s8.4,\sand\sapplies\sto\s8.4.11rc5.\s\sIt\sworks\sby\ndelaying\scleanup\sof\sthe\spipe\ssubsystem\suntil\nafter\sall\schannels\sare\sclosed.\s\sIt\salso\sadds\nan\sassertion\sin\sTcl_Finalize\sthat\sno\sexit\nhandlers\shave\sbeen\screated\sin\sthe\sdead\nprocess.\n
J foundin obsolete:\s8.4.11
J priority 9\sImmediate
J resolution None
J status Open
J submitter kennykb
J subsystem 27.\sChannel\sTypes
J title crash\swhen\sprocess\sexits\swith\sopen\spipes
J type Bug
K 1225727fffffffffffffffffffffffffffffffff
U kennykb
Z 12d4d8a8dc8c2cecf5e2ee14d73c1961