public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Bash silently truncates the Command Line when called programatically via CreateProcess as MAXPATHLEN was reduced to 8192 from 16384
@ 2014-05-26 17:28 Abhijit Bhattacharjee
  2014-05-26 20:38 ` Christopher Faylor
  0 siblings, 1 reply; 13+ messages in thread
From: Abhijit Bhattacharjee @ 2014-05-26 17:28 UTC (permalink / raw)
  To: cygwin

On a typical configuration, we use gmake on windows as the build
system. GMAKE calls the Cygwin bash in order to invoke the MSVS
compiler in-order to satisfy the dependency if a rule to call the
compiler is present.
Now, for certain modules, the command line was seemingly getting
truncated. On investigating further it revealed the reason for the
truncation was because in the glob.cc, MAXPATHLEN was now defined as
8192 so, when bash was compiled with the changed crt code, the problem
started to emerge.

Now, it also seems that there was a discussion
(https://cygwin.com/ml/cygwin-patches/2012-q1/msg00037.html) where
Corinna mentioned about decreasing the size to 4096 and later
increasing it to 8192. Unfortunately, for our case, 8192 is low a
limit and ideally the previous limit of 16384 was working perfectly.

The Argument that Corinna placed was because the default stack size is
2 Megs  and sizeof(Char)==8, a local array of 8* 16384  would be too
strenuous for the stack.

It was still not clear to me as to why?

1. The Temporary buffer was not allocated on heap?
2. Why the entire argument (both quoted and non-quoted string) was
passed to the glob module. If instead, the argument string could had
been tokeinized  as interleaving quoted and non-quoted string, the
restriction imposed on the argument length would be alleviated. What I
am envisaging is, currently in the globify module, you are escaping
all the quoted characters to demarcate from the non-quoted characters
before calling glob once, so that the glob can only expand non-quoted
sub-string. Instead, if we could call glob multiple times whenever we
encounter a sub-string of non-quoted string, wouldn't it be cleaner?


In any case, as of now, for the time being I have increased the size
of MAXPATHLEN back to 16384  and recompiled the cygwin followed by
bash but am looking forward for a solution from your end, as this is
dirty, difficult to maintain, and likely to break in the future as our
cygwin build is different from what we have in the repository.



Rgrds,
Abhijit

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: Bash silently truncates the Command Line when called  programatically via CreateProcess as MAXPATHLEN was reduced to 8192 from  16384
@ 2014-05-28 16:07 Houder
  2014-05-28 17:59 ` Christopher Faylor
  0 siblings, 1 reply; 13+ messages in thread
From: Houder @ 2014-05-28 16:07 UTC (permalink / raw)
  To: cygwin

Hi Abhijit,

> Please note, when I am saying the path is getting truncated, its the
> bash that is truncating it. Also, its immaterial how and what is
> getting called. With the latest Cygwin, any program that is compiled
> and linked with the CRT would exhibit this behavior. The truncation
> issue in the CRT is best demonstrated by the following Code couplets
>
> Caller.cpp
> --------------
> [snip]
>
> Callee.cpp
> -------------
> [snip]

Using your code couplets (and modifying them a bit), I did some experimentation, and observed:

 - the first parameter to callee, if quoted, is truncated to 8186 bytes in case the length of
   the argument without quotes, exceeds the aforementioned length.
 - no truncation occurs in case the parameter is not quoted.

As far as I can tell, it is not bash, but the Cygwin supervisor, that does the truncation.

Henri


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-05-31 19:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 17:28 Bash silently truncates the Command Line when called programatically via CreateProcess as MAXPATHLEN was reduced to 8192 from 16384 Abhijit Bhattacharjee
2014-05-26 20:38 ` Christopher Faylor
2014-05-27  3:18   ` René Berber
2014-05-27  6:54     ` Christopher Faylor
     [not found]       ` <CANMjiJpDU-aVxg1X8G_Lk8pKLEmXbs24+ieD=w3f8ZmQ2jdjTw@mail.gmail.com>
2014-05-27 22:11         ` Abhijit Bhattacharjee
2014-05-28  9:48           ` Christopher Faylor
2014-05-28 11:04           ` David Stacey
2014-05-28 19:48             ` Warren Young
2014-05-31 13:37               ` Abhijit Bhattacharjee
2014-05-31 17:55                 ` Cliff Hones
2014-05-31 19:22                 ` Christopher Faylor
2014-05-28 16:07 Houder
2014-05-28 17:59 ` Christopher Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).