From: Keith M. <kei...@to...> - 2006-10-25 15:31:16
|
John Vanderberg wrote, quoting me: >> Tomer Ben-Chen wrote: >>> I checked again, it is definitely a bug. It happens only when >>> calling the program from a relative location (for example, up >>> a directory - see below). >> >> Indeed, I can reproduce this, but only when the relative path is >> composed *entirely* of `..' references. >> >>> I'm using MSYS version 1.0.10 ... >> >> As am I ... > > I can reproduce this as well on 1.0.11(0.46/3/2) 2004-04-30. I > have found a workaround, but first... > > $ ../dumpargs.exe - -abc > argv[0]: c:\workspace\dumpargs.exe > argv[1]: -C:/msys/1.0/dumpa > argv[2]: -abc > > $ cp ../dumpargs.exe ../printargs.exe > > $ ../printargs - -abc > argv[0]: c:\workspace\printargs.exe > argv[1]: -C:/msys/1.0/print > argv[2]: -abc > > And here is where the problem goes away... > > $ ../printargs.exe - -abc > argv[0]: c:\workspace\printargs.exe > argv[1]: - > argv[2]: -abc > > And by reduce the length of the command, I can make it come back > again (whee...) Ok, thanks John. I see something similar with 1.0.10: $ cd foo $ cp ../dumpargs.exe ../a.exe $ a=a $ until test $a = aaaaaaaaaaaaaaaa > do > echo \$ ../$a - -abc > ../$a - -abc > mv ../$a.exe ../a$a.exe > a=a$a > done; rm ../aaa*.exe $ ../a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -a:/ argv[2]: -abc $ ../aa - -abc argv[0]: D:\MSYS\1.0\home\keith\aa.exe argv[1]: -D:/MSYS/1.0/aa argv[2]: -abc $ ../aaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaa.exe argv[1]: -D:/MSYS/1.0/aaa argv[2]: -abc $ ../aaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaa.exe argv[1]: -D:/MSYS/1.0/aaaa argv[2]: -abc $ ../aaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaaaaaa.exe argv[1]: -D:/MSYS/1.0/aaaaa argv[2]: -abc $ ../aaaaaaaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaaaaaaa.exe argv[1]: - argv[2]: -abc $ ../aaaaaaaaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaaaaaaaa.exe argv[1]: - argv[2]: -abc $ ../aaaaaaaaaaaaaaa - -abc argv[0]: D:\MSYS\1.0\home\keith\aaaaaaaaaaaaaaa.exe argv[1]: - argv[2]: -abc So, it seems that: - for very short command names, the initial `-' argv[1] gets extended, by appending `<msys-root>/<basename argv[0]>' - as the length of the executable name increases, the extra chars appended to argv[1] are truncated after some fixed length - as the length of the name increases further, to exceed 12 chars, the value of argv[1] is no longer corrupted. And, BTW, my earlier statement that this anomaly only appears if the relative path is composed only of `..' entities wasn't true: $ mkdir -p a/b $ cp dumpargs.exe a/a.exe $ cd a/b $ ../../a/a - -abc seems to expose it, while $ cd foo $ ../../keith/dumpargs - -abc makes the command name long enough to conceal it. > So, it looks like it is the length of the command name that triggers > this bug. Indeed, there does appear to be some correlation. > fyi, this looks very similar to the problem I reported in July last > year: > > http://lists.zerezo.com/mingw-msys/msg00525.html > > My workaround was to use double-slashes instead of single-slashes; > perhaps a similar workaround can be found for this problem... > > $ ../dumpargs.exe - -abc > argv[0]: c:\workspace\dumpargs.exe > argv[1]: -C:/msys/1.0/dumpa > argv[2]: -abc > > $ ..//dumpargs.exe - -abc > argv[0]: c:\workspace\dumpargs.exe > argv[1]: - > argv[2]: -abc > > Look at that ... double-slashes and the problem disappears :-) Nope. While there does appear to be some effect, that isn't sufficient, even as a work around -- sorry, but... $ pwd /home/keith/foo $ cp ../dumpargs.exe ../a.exe $ a=a $ until test $a = //////////////// > do > echo \$ ..${a}a - -abc > eval ..${a}a - -abc > a=$a/ > done; rm ../a.exe $ ../a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -a:/ argv[2]: -abc $ ..//a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -/a argv[2]: -abc $ ..///a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -//a argv[2]: -abc $ ..////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///a argv[2]: -abc $ ../////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -////a argv[2]: -abc $ ..//////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///// argv[2]: -abc $ ..///////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///// argv[2]: -abc $ ..////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///// argv[2]: -abc $ ../////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///// argv[2]: -abc $ ..//////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///// argv[2]: -abc $ ..///////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///// argv[2]: -abc $ ..////////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: -///// argv[2]: -abc $ ../////////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: - argv[2]: -abc $ ..//////////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: - argv[2]: -abc $ ..///////////////a - -abc argv[0]: D:\MSYS\1.0\home\keith\a.exe argv[1]: - argv[2]: -abc Regards, Keith. |