Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crash TCL by repeated executing a shell

Status
Not open for further replies.

esjo

Programmer
Sep 13, 2000
15
DE
I use TCL/TK 8.3.2 under WINNT 4.0.

For generating filed based checksums I'd to absolve a loop containing an "exec"-command.
When then number of files reaches the limit of some thousand files the script breakes and the TCL-parser is frozen.
To reach that point it's irrelevant, what "*.exe" is called within the loop - take any executable you like, build a loop of some thousand passes and the script will crash. It works both {exec xxxx.exe parameters} and {open "| xxxx.exe parameters"}. The task-manager shows a gentle increasing of memory usage - it seems to me, that ressources were not released after closing the used Shell.

For example the loop

for {set count 10000} {$count > 0} {incr count -1} {set dummy [exec "C:\\WINNT\\system32\\hostname.exe"]}

crashes after about 3000 passes.

Is there a way to void this culminating effect ?
Thanks.

 
Is it Tcl that crashes or does the OS lock up? Bob Rashkin
rrashkin@csc.com
 
Knowing that it is windows (even NT which is Okay),
my best bet is 50%-50% either way.

One way to test would be (if the example above is correct)
to use an equivalent tcl operation that gives you control
over the process to isolate the problem.
for instance:
for (set m 125000} {$m > 0} {incr m -1} {
set name$m [open "| myapp.exe $target"]
get_info $name$m ; catch {close $name$m} err_close$m
}
But, for some apps, and especially in windows, this is
problematic.

As a modest test, approximate the applications
functionality in pure tcl.
To use your example: hostname.exe (A resolver utility right?)
Using the native tcl, tnm extension, you can
perform the identical operation:
package require Tnm 2.0
set rr [dns address -retries 1 -timeout 25 $target]
If it does not hang, you have a solution in any case.

 
Actually, there is a known memory leak in Tcl's I/O subsystem in version 8.3.2. For an application like this, I'd strongly recommend upgrading to the latest version, 8.3.4, which has corrected the memory leak problem. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Thanks for your responses!

Here the answers of your questions:

to "Bong":
It's only the TCL-Subshell that crashes; the OS is free.

to "Bob Rashkin":
The construct
{set [ channel [ open "| ***.exe" "parameters" ] ... and so on}
I use usually ( so I can catch the stdout ). Only for testing I used the "exec"-construct. But both variants result in "hangin' up".
A pure TCL-functionallity is to slow - the "MD5.exe" is a fast executable to generate a checksum of a file by using the MD5-method. The other executables I only used in the test to rule out a internal fault in the MD5.exe. So I found, that every WIN-executable you call crash, when the call is placed within a loop of some thousand passes.
A TCL-built-in function to generate a checksum of a file i didn't found. Is there such one, I don't know ?

to "AviaTraining":
Thanks for the tip to upgrade to TCL 8.3.4.. I did this today and there were two results:
The good one: The memory usage don't increase during the loop;
and the bad one: after about 2300 passes the script crashes as had.

Now I'm at a loss.
Any new Ideas ?

 
it's marsd, not Bob Rashkin.
In any case: I haven't been able to find anything on calculating md5 sums ala the md5(bhash,doc.length(),etc..)form used by other languages. However tcl does have a simple
md5 library that ships 8.2+: package require MD5.
You could roll your own md5 script if you were feeling ambitious.
I wrote a small test script just looking at it based
on file stat. If you are interested I'll post it.








 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top