Re: Unable to execute Cygwin application within UDF format
On Sat, 28 May 2022 09:22:12 -0400 Ken Brown wrote: > On 5/27/2022 8:36 AM, Takashi Yano wrote: > > diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc > > index 01b49468e..34c9e2bc7 100644 > > --- a/winsup/cygwin/cygheap.cc > > +++ b/winsup/cygwin/cygheap.cc > > @@ -183,6 +183,11 @@ init_cygheap::init_installation_root () > > if (p) > > p = wcschr (p + 1, L'\\'); /* Skip share name */ > > } > > + else > > + { > > + len = 4; > > + p = installation_root_buf + 4; > > + } > > } > > installation_root_buf[1] = L'?'; > > RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, > > This looks right to me. I would just suggest an explanatory comment, > something > like this: > > + else /* Long path prefix followed by drive letter path */ Thanks for the advice. I will submit the patch to cygwin-patches mailing list. -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On 5/27/2022 8:36 AM, Takashi Yano wrote: diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 01b49468e..34c9e2bc7 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -183,6 +183,11 @@ init_cygheap::init_installation_root () if (p) p = wcschr (p + 1, L'\\'); /* Skip share name */ } + else + { + len = 4; + p = installation_root_buf + 4; + } } installation_root_buf[1] = L'?'; RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, This looks right to me. I would just suggest an explanatory comment, something like this: + else /* Long path prefix followed by drive letter path */ Ken -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On 27/05/2022 10:18, Takashi Yano wrote: On Fri, 27 May 2022 16:47:09 +0800 Sam Lin wrote: I have also successfully executed that is to move cygwin1.dll to the root directory to execute. Will cygwin1.dll be supported to execute in UDF format in the future? As I wrote earlier, it doesn't matter that the file system is UDF. cygwin1.dll 3.2.0 and later seems to cause problems if it is placed in the root directory. Even with UDF format, the problem does not occur if hello.exe and cygwin1.dll are placed in any directory other than root directory. Perhaps the Cygwin DLL is trying to identify the Cygwin root directory as one higher than its own location so that it can locate /etc/fstab etc. If it's in the root of a drive maybe it's getting confused. Create an x:\bin\ directory (where x is the drive letter of the UDF device) into which to place cygwin1.dll and the executable. -- Sam Edge -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On Fri, 27 May 2022 21:28:13 +0900 Takashi Yano wrote: > On Fri, 27 May 2022 19:51:23 +0900 > Takashi Yano wrote: > > diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc > > index 01b49468e..c4031b919 100644 > > --- a/winsup/cygwin/cygheap.cc > > +++ b/winsup/cygwin/cygheap.cc > > @@ -183,6 +183,8 @@ init_cygheap::init_installation_root () > > if (p) > > p = wcschr (p + 1, L'\\'); /* Skip share name */ > > } > > + else > > + p = installation_root_buf + 4; /* 4 is the length of "?\\" */ > > } > >installation_root_buf[1] = L'?'; > >RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, > > I think the following patch makes more sense. > > diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc > index 01b49468e..5623c9f5f 100644 > --- a/winsup/cygwin/cygheap.cc > +++ b/winsup/cygwin/cygheap.cc > @@ -183,6 +183,11 @@ init_cygheap::init_installation_root () > if (p) > p = wcschr (p + 1, L'\\'); /* Skip share name */ > } > + else if (!wcsncmp (p + 2, L"?\\", 2)) > + { > + len = 4; > + p = installation_root_buf + 4; > + } > } >installation_root_buf[1] = L'?'; >RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, Ah, wcsncmp() check is redundant here. So it is better: diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 01b49468e..34c9e2bc7 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -183,6 +183,11 @@ init_cygheap::init_installation_root () if (p) p = wcschr (p + 1, L'\\'); /* Skip share name */ } + else + { + len = 4; + p = installation_root_buf + 4; + } } installation_root_buf[1] = L'?'; RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On Fri, 27 May 2022 19:51:23 +0900 Takashi Yano wrote: > diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc > index 01b49468e..c4031b919 100644 > --- a/winsup/cygwin/cygheap.cc > +++ b/winsup/cygwin/cygheap.cc > @@ -183,6 +183,8 @@ init_cygheap::init_installation_root () > if (p) > p = wcschr (p + 1, L'\\'); /* Skip share name */ > } > + else > + p = installation_root_buf + 4; /* 4 is the length of "?\\" */ > } >installation_root_buf[1] = L'?'; >RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, I think the following patch makes more sense. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 01b49468e..5623c9f5f 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -183,6 +183,11 @@ init_cygheap::init_installation_root () if (p) p = wcschr (p + 1, L'\\'); /* Skip share name */ } + else if (!wcsncmp (p + 2, L"?\\", 2)) + { + len = 4; + p = installation_root_buf + 4; + } } installation_root_buf[1] = L'?'; RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On Fri, 27 May 2022 18:18:49 +0900 Takashi Yano wrote: > On Fri, 27 May 2022 16:47:09 +0800 > Sam Lin wrote: > > I have also successfully executed that is to move cygwin1.dll to the root > > directory to execute. > > > > Will cygwin1.dll be supported to execute in UDF format in the future? > > As I wrote earlier, it doesn't matter that the file system > is UDF. cygwin1.dll 3.2.0 and later seems to cause problems > if it is placed in the root directory. > > Even with UDF format, the problem does not occur if hello.exe > and cygwin1.dll are placed in any directory other than root > directory. I looked into this problem and found the problem occurs after the commit: commit 6d898f43fc87a7bf3ab100d75538e381bd86f657 Author: Corinna Vinschen Date: Fri Feb 19 18:15:58 2021 +0100 Cygwin: realpath: fix cygwin installation dir being access via junction Consider this case: - Cygwin installed in C:\cygwin64 - mklink /j D:\cygwin64 C:\cygwin64 - create testcase calling realpath("/", result); printf ("%s\n", result); - start cmd >C:\cygwin64\bin\bash -lc / >D\cygwin64\bin\bash -lc /cygdrive/c/cygwin64 This scenario circumventing the mount point handling which is automated in terms of /, depending on the path returned from GetModuleFileNameW for the Cygwin DLL. When calling D:\cygwin64\bin\bash the dir returned from GetModuleFileNameW is D:\cygwin64\bin, thus root is D:\cygwin64. However, junctions are treated as symlinks in Cygwin which explains why the path gets converted to a cygdrive path. Fix this by calling GetFinalPathNameByHandleW on the result from GetModuleFileNameW to get the correct root path, even if accessed via a junction point. Signed-off-by: Corinna Vinschen And also found the following patch fixes the issue. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 01b49468e..c4031b919 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -183,6 +183,8 @@ init_cygheap::init_installation_root () if (p) p = wcschr (p + 1, L'\\'); /* Skip share name */ } + else + p = installation_root_buf + 4; /* 4 is the length of "?\\" */ } installation_root_buf[1] = L'?'; RtlInitEmptyUnicodeString (&installation_key, installation_key_buf, -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On Fri, 27 May 2022 16:47:09 +0800 Sam Lin wrote: > I have also successfully executed that is to move cygwin1.dll to the root > directory to execute. > > Will cygwin1.dll be supported to execute in UDF format in the future? As I wrote earlier, it doesn't matter that the file system is UDF. cygwin1.dll 3.2.0 and later seems to cause problems if it is placed in the root directory. Even with UDF format, the problem does not occur if hello.exe and cygwin1.dll are placed in any directory other than root directory. -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
Hi , I have also successfully executed that is to move cygwin1.dll to the root directory to execute. Will cygwin1.dll be supported to execute in UDF format in the future? Thanks, Sam Takashi Yano 於 2022年5月27日 週五 下午12:32寫道: > On Fri, 27 May 2022 11:36:27 +0800 > Sam Lin wrote: > > I will see the problem on WIN10 or WIN SERVER, the duplicate steps are as > > follows: > > > > 1. Write a simple code 'hello world' program and compiled the > > executable file using GCC. > > > > // hello.c > > #include > > > > int main() { > > printf("Hello World\n"); > > return 0; > > } > > > > $ gcc hello.c -o hello.exe > > > > 2. Format the specified USB drive using command prompt. > > C:\> format : /fs:UDF /q > > > > 3. Put the executable files hello.exe and cygwin1.dll into the UDF format > > flash drive and execute. > > We will find that the execution error occurs with cygwin v3.2.x and > above. > > > > F:\>hello.exe > > 0 [main] hello (16224) F:\hello.exe: *** fatal error - add_item > > ("\??", "/", ...) failed, errno 22 > > Stack trace: > > FrameFunctionArgs > > 000CCE0 001800622EE (0018029F172, 0018027AE81, 008, > > 0008B40) > > 000CCE0 0018004874A (000, 000CCE0, 00180020010, > > 000ABD6) > > 000CCE0 00180048782 (0009BD0, 016, 008, > > 001) > > 000CCE0 001800E30BC (000CBD0, 000CDF0, 001800D7488, > > 000) > > 000CCE0 00180133DC5 (001800D344A, 000, 000, > > 000) > > 000CCE0 00180048DA5 (000, 000, 000, > > 000) > > 000FFF0 00180047856 (000, 000, 000, > > 000) > > 000FFF0 00180047904 (000, 000, 000, > > 000) > > End of stack trace > > > > This error does not occur in v3.1.7. > > Hope this will be resolved in the future. > > This seems to happen if cygwin1.dll is placed in the root > directly regardless of file system type. > > -- > Takashi Yano > > -- > Problem reports: https://cygwin.com/problems.html > FAQ: https://cygwin.com/faq/ > Documentation:https://cygwin.com/docs.html > Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple > -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On Fri, 27 May 2022 13:31:20 +0900 Takashi Yano wrote: > On Fri, 27 May 2022 11:36:27 +0800 > Sam Lin wrote: > > I will see the problem on WIN10 or WIN SERVER, the duplicate steps are as > > follows: > > > > 1. Write a simple code 'hello world' program and compiled the > > executable file using GCC. > > > > // hello.c > > #include > > > > int main() { > > printf("Hello World\n"); > > return 0; > > } > > > > $ gcc hello.c -o hello.exe > > > > 2. Format the specified USB drive using command prompt. > > C:\> format : /fs:UDF /q > > > > 3. Put the executable files hello.exe and cygwin1.dll into the UDF format > > flash drive and execute. > > We will find that the execution error occurs with cygwin v3.2.x and above. > > > > F:\>hello.exe > > 0 [main] hello (16224) F:\hello.exe: *** fatal error - add_item > > ("\??", "/", ...) failed, errno 22 > > Stack trace: > > FrameFunctionArgs > > 000CCE0 001800622EE (0018029F172, 0018027AE81, 008, > > 0008B40) > > 000CCE0 0018004874A (000, 000CCE0, 00180020010, > > 000ABD6) > > 000CCE0 00180048782 (0009BD0, 016, 008, > > 001) > > 000CCE0 001800E30BC (000CBD0, 000CDF0, 001800D7488, > > 000) > > 000CCE0 00180133DC5 (001800D344A, 000, 000, > > 000) > > 000CCE0 00180048DA5 (000, 000, 000, > > 000) > > 000FFF0 00180047856 (000, 000, 000, > > 000) > > 000FFF0 00180047904 (000, 000, 000, > > 000) > > End of stack trace > > > > This error does not occur in v3.1.7. > > Hope this will be resolved in the future. > > This seems to happen if cygwin1.dll is placed in the root > directly regardless of file system type. I meant "root directory". -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Re: Unable to execute Cygwin application within UDF format
On Fri, 27 May 2022 11:36:27 +0800 Sam Lin wrote: > I will see the problem on WIN10 or WIN SERVER, the duplicate steps are as > follows: > > 1. Write a simple code 'hello world' program and compiled the > executable file using GCC. > > // hello.c > #include > > int main() { > printf("Hello World\n"); > return 0; > } > > $ gcc hello.c -o hello.exe > > 2. Format the specified USB drive using command prompt. > C:\> format : /fs:UDF /q > > 3. Put the executable files hello.exe and cygwin1.dll into the UDF format > flash drive and execute. > We will find that the execution error occurs with cygwin v3.2.x and above. > > F:\>hello.exe > 0 [main] hello (16224) F:\hello.exe: *** fatal error - add_item > ("\??", "/", ...) failed, errno 22 > Stack trace: > FrameFunctionArgs > 000CCE0 001800622EE (0018029F172, 0018027AE81, 008, > 0008B40) > 000CCE0 0018004874A (000, 000CCE0, 00180020010, > 000ABD6) > 000CCE0 00180048782 (0009BD0, 016, 008, > 001) > 000CCE0 001800E30BC (000CBD0, 000CDF0, 001800D7488, > 000) > 000CCE0 00180133DC5 (001800D344A, 000, 000, > 000) > 000CCE0 00180048DA5 (000, 000, 000, > 000) > 000FFF0 00180047856 (000, 000, 000, > 000) > 000FFF0 00180047904 (000, 000, 000, > 000) > End of stack trace > > This error does not occur in v3.1.7. > Hope this will be resolved in the future. This seems to happen if cygwin1.dll is placed in the root directly regardless of file system type. -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
Unable to execute Cygwin application within UDF format
Hi , I will see the problem on WIN10 or WIN SERVER, the duplicate steps are as follows: 1. Write a simple code 'hello world' program and compiled the executable file using GCC. // hello.c #include int main() { printf("Hello World\n"); return 0; } $ gcc hello.c -o hello.exe 2. Format the specified USB drive using command prompt. C:\> format : /fs:UDF /q 3. Put the executable files hello.exe and cygwin1.dll into the UDF format flash drive and execute. We will find that the execution error occurs with cygwin v3.2.x and above. F:\>hello.exe 0 [main] hello (16224) F:\hello.exe: *** fatal error - add_item ("\??", "/", ...) failed, errno 22 Stack trace: FrameFunctionArgs 000CCE0 001800622EE (0018029F172, 0018027AE81, 008, 0008B40) 000CCE0 0018004874A (000, 000CCE0, 00180020010, 000ABD6) 000CCE0 00180048782 (0009BD0, 016, 008, 001) 000CCE0 001800E30BC (000CBD0, 000CDF0, 001800D7488, 000) 000CCE0 00180133DC5 (001800D344A, 000, 000, 000) 000CCE0 00180048DA5 (000, 000, 000, 000) 000FFF0 00180047856 (000, 000, 000, 000) 000FFF0 00180047904 (000, 000, 000, 000) End of stack trace This error does not occur in v3.1.7. Hope this will be resolved in the future. Thanks, Sam -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation:https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple