Mail Archives: cygwin/2014/05/27/09:20:46
Yes, MSVS is Microsoft Visual Studio.
and I am using the make for Windows
(http://gnuwin32.sourceforge.net/packages/make.htm).
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
--------------
#include <iostream>
#include <windows.h>
#include <string.h>
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
int main(int argc, char *argv[]) {
if (argc <= 1) return -1;
char arg[10000] = {0};
strncpy(arg, argv[argc-1], _countof(arg));
strncat(arg," ", _countof(arg));
memset(arg + strlen(arg), 'X', _countof(arg) - strlen(arg) - 2);
strncat(arg, "\"", _countof(arg));
STARTUPINFO startInfo;
PROCESS_INFORMATION procInfo;
memset( &startInfo, 0, sizeof(startInfo) );
memset( &procInfo, 0, sizeof(procInfo) );
if (CreateProcess(NULL,
arg,
NULL,
0,
TRUE,
0,
NULL,
NULL,
&startInfo,
&procInfo) == FALSE) {
std::cout<<"Error Code "<<GetLastError()<<std::endl;
} else {
WaitForSingleObject(procInfo.hProcess, INFINITE );
CloseHandle( procInfo.hProcess );
CloseHandle( procInfo.hThread );
std::cout<<"Send Length "<<strlen(arg)<<std::endl;
}
return 0;
};
Callee.cpp
-------------
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <windows.h>
int main (int argc, char **argv) {
printf("%s\n",argv[argc-1]);
printf("%d\n",argc);
printf("Received Length %d\n",strlen(argv[argc-1]));
return 0;
}
Compile and Run The Programs as
-----------------------------------------
$g++ -g -o Caller.exe Caller.cpp
$g++ -g -o Callee.exe Callee.cpp
$./Caller.exe Callee.exe
Also Note, if you would like to review the code that is responsible
for the truncation, I would suggest you to refer the function
Source: winsup\cygwin\glob.cc
int glob(const char *__restrict pattern, int flags, int
(*errfunc)(const char *, int), glob_t *__restrict pglob)
and notice pathbuf is defined as
Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
where
#undef MAXPATHLEN
#define MAXPATHLEN 8192
and to complete here is the call stack
glob(const char *__restrict pattern, int flags, int (*errfunc)(const
char *, int), glob_t *__restrict pglob)
globify (char *word, char **&argv, int &argc, int &argvlen) - Line
265 of winsup\cygwin\dcrt0.cc
build_argv (char *cmd, char **&argv, int &argc, int winshell) - Line
353 of winsup\cygwin\dcrt0.cc
dll_crt0_1 (void *) - Line 953 of winsup\cygwin\dcrt0.cc
_dll_crt0 () - Line 1098 of winsup\cygwin\dcrt0.cc
dll_crt0 - Line 1110 of winsup\cygwin\dcrt0.cc
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
- Raw text -