exec-18.1 fails under WinNT
Closed / Fixed578159ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 23 years ago
Descriptionplain2002-07-06 17:50:13
The 'exec-18.1' test fails under Windows NT 4.0SP6 in the
latest HEAD:
==== exec-18.1 exec cat deals with weird file names FAILED
==== Contents of test case:
set f "foo\[\{blah"
set path(fooblah) [makeFile {} $f]
set fout [open $path(fooblah) w]
puts $fout "contents"
close $fout
set res [list [catch {exec cat $path(fooblah)} msg] $msg]
removeFile $f
set res
---- Result was:
1 {/usr/bin/cat: D:/SourceForge/tcl/win/foo[\: No such file or directory}
---- Result should have been (exact matching):
0 contents
==== exec-18.1 FAILED
kennykb Ticket [578159ffff]: 1 change
[History diff]2002-07-07 01:02:36
nobodyplain2002-07-08 15:44:33
Logged In: NO Given this worked a week ago, I think it is due to the various tcltest and test suite changes that this has now broken, and is not a channel problem at all.
vincentdarleyplain2002-07-08 19:24:06
Logged In: YES
user_id=32170
The previous version of test 18.1:
test exec-18.1 { exec cat deals with weird file names}
{execCommandExists} {
set f "foo\[\{blah"
set fout [open $f w]
puts $fout "contents"
close $fout
set res [list [catch {exec cat $f} msg] $msg]
file delete $f
set res
} {0 contents}
works fine, so the problem is in the makeFile etc
changes introduced three days ago by Andreas (or in the
actual functions 'tcltest::makeFile' etc themselves)
andreas_kupriesplain2002-07-09 03:33:25
Logged In: YES
user_id=75003
Sorry Vince. The difference the between the old and new
testcase is whether 'exec cat' is given a relative path (old), or
an absolute path (new).
I added some debug output to winPipe, to get a look at the
actual command executed (in BuildCommandLine, just before
the conversion to TChar*).
The old test runs:
C:\cygwin\bin\cat.exe foo[\{blah
and the new test calls
C:\cygwin\bin\cat.exe
C:/cygwin/home/Administrator/84/b/foo[\{blah
In the second case something cuts the path off after the '[\',
just before the brace. Adding a [file nativename] around the
absolute path does not help. The command now run is
C:\cygwin\bin\cat.exe C:\cygwin\home\Administrator\84
\b\foo[\{blah
and is cut off as before.
To me this looks like a quoting issue in exec, and not as a
problem of the testcase. Except that the testcase uncovers
the problem now.
Handing over.
davygrvyplain2002-07-09 09:38:10
Logged In: YES user_id=7549 >To me this looks like a quoting issue in exec, and not as a >problem of the testcase. Except that the testcase uncovers >the problem now. If what BuildCommandline is outputing correctly, but the result of what's launched is wrong, then the quoting rules used for concatenating argv into a string aren't proper for CreateProcess(). There's some funny stuff with how CreateProcess() expects it's commandline and doesn't seem to be documented well. Esentially, it goes from array->string->array through the system and the last array goes out wrong. I've seen this before, but don't have a good hold on why.
davygrvyplain2002-07-09 10:00:10
Logged In: YES user_id=7549 see 528669 as well. SetArgv() from tclAppInit.c should equal BuildCommandLine() but in reverse. At least, that's the concept and might be an msvcrt bug...
vincentdarleyplain2002-07-09 16:03:33
Logged In: YES user_id=32170 'fraid this isn't my area of expertise at all. All I know is that this used not to work, then it was fixed recently, but now this new failure seems to indicate that it was only a partial fix, which worked for a simple relative path, but not for an absolute one.
davygrvyplain2002-07-09 18:02:51
Logged In: YES
user_id=7549
[exec] itself seems OK from this:
% set f "foo\[\{blah"
foo[{blah
% exec cmd.exe /c echo $f
foo[{blah
%
--still testing--
vincentdarleyplain2002-07-09 19:16:43
Logged In: YES
user_id=32170
It would seem to be a bug in cat?
% exec cat /c/foo\[\{blah
contents
% exec cat c:/foo\[\{blah
/usr/bin/cat: c:/foo[\: No such file or directory
% exec cat foo\[\{blah
contents
%
nobodyplain2002-07-09 22:42:57
Logged In: NO
Since it looks as if 'exec' is working, and just 'cat' is
broken, perhaps this test can be marked 'knownBug' (on
Windows anyway) with a comment to the effect that it is
a problem in cat, and a new test can be added which
does a 'cd $tempDirectory' and only uses the file tail of
the [{ path.
Then we can close this bug (but perhaps someone
should report the problem to whoever maintains
cygwin's 'cat').
That's if my understanding of the situation is right...
kennykbplain2002-07-09 23:50:07
Logged In: YES user_id=99768 Perhaps we could use some Tcl script in place of 'cat'? Or use a Windows-supplied command in place of it? (Why an extra dependency on cygwin, anyway?)
andreas_kupriesplain2002-07-10 00:22:09
Logged In: YES
user_id=75003
Please note that all the failing commands are completely ok
when cat is run from the cygwin bash shell. To me this
indicates that there is no error in 'cat', but in the way exec
provides the arguments to it. The only way to be sure is to
get hold of the sources of cat and modify it to display the
arguments it gets. Speculation: Given that the filename is
cutoff immediately after the last \, used to quote the brace:
cat might get the full filename, i.e. no error in exec, but
interpret the \{ as path-separator + brace, and report a
missing directory.
The original bug report which prompted this new testcase was
http://sourceforge.net/tracker/index.php?
func=detail&aid=554068&group_id=10894&atid=110894
As this is about [exec] an external application is required.
Wht we could do is to execute a small test script which
simply reports the arguments it got, instead of 'cat'.
davygrvyplain2002-07-10 02:12:12
Logged In: YES user_id=7549 >To me this >indicates that there is no error in 'cat', but in the way exec >provides the arguments to it. There might be some "funny stuff" in the way cat.exe parses GetCommandLine() [the string] into it's argv array that might be a bit different than the "accepted way". That's the shyly documented part of CreateProcess() and seems to be left to the C run-time. Having the invoker [bash] launch the child [cat], there's a very good chance the parsing rules are a pure pass-through with a possibly different parsing rule set that this test happens to be exercising now. I can't say for sure if `cmd.exe /c echo` is a good test either for testing argv parsing. Can we assume the "accepted way" is the algorithm in msvcrt's setargc.c for parse_cmdline()?
davygrvyplain2002-07-10 07:44:29
Logged In: YES user_id=7549 >Can we assume the "accepted way" is the algorithm in >msvcrt's setargc.c for parse_cmdline()? Whoops, I meant msvcrt's parse_cmdline() found in crt/src/stdargv.c
davygrvyplain2002-07-10 09:22:01
Logged In: YES
user_id=7549
Should I put together a command in tclTest.c for asserting
cases for tclWinPipe.c's BuildCommandLine() vs. msvcrt's
parse_cmdline() ? I did something like this for Expect and it
looked like this:
// Test the full pass-thru
//
int TestPassThruCmd (int objc, struct Tcl_Obj * CONST
objv[])
{
char **argvIn = new char * [objc-1];
int i, argc;
char *line, **argv;
Tcl_Obj **oobjv;
// Take the array and turn it into a string.
for (i = objc-1; i > 0; i--) argvIn[i-1] = Tcl_GetString
(objv[i]);
line = BuildCommandLine(objc-1, argvIn);
// Now take the string and turn it back into an
array.
SetArgv(line, &argc, &argv);
delete [] line;
oobjv = new Tcl_Obj * [argc];
for (i = 0; i < argc; i++) oobjv[i] = Tcl_NewStringObj
(argv[i], -1);
Tcl_SetObjResult(interp, Tcl_NewListObj(argc,
oobjv));
return TCL_OK;
}
andreas_kupriesplain2002-07-10 10:13:26
Logged In: YES user_id=75003 A good idea. Yes, please.
hobbs Ticket [578159ffff]: 1 change
[History diff]2002-08-08 14:14:55
dgp Ticket [578159ffff]: 1 change
[History diff]2003-01-07 06:16:26
hobbsplain2003-11-11 04:24:05
Logged In: YES user_id=72656 No test failure in pre-8.4.5 cvs.
Log in (anonymous is fine) to add a comment.