public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
@ 2022-01-12  4:12 Jay K
  2022-01-12  5:57 ` Jay K
  0 siblings, 1 reply; 9+ messages in thread
From: Jay K @ 2022-01-12  4:12 UTC (permalink / raw)
  To: cygwin

I get this a lot:

      0 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    452 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    716 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
   1652 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
      0 [main] sh 7775 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?

Scenario is multi-threaded "launching" a bunch of invocations of gcc.
"launching" was usually spawnve or fork/execve but I changed the code to use system and it still happens.
I might try to make a small reproducing, if this is not known.
It seems a bit difficult to believe I could cause this internal looking error.

Thank you,
 - Jay

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

* Re:  proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-12  4:12 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 Jay K
@ 2022-01-12  5:57 ` Jay K
  2022-01-12  6:27   ` Jay K
  0 siblings, 1 reply; 9+ messages in thread
From: Jay K @ 2022-01-12  5:57 UTC (permalink / raw)
  To: cygwin

Um, I know this isn't (yet) diligent/scientific, but must system create this thread?

#0  0x00007ff811e09e47 in KERNEL32!CreateThread () from /cygdrive/c/WINDOWS/System32/KERNEL32.DLL
#1  0x00000001800468eb in cygthread::create() () from /usr/bin/cygwin1.dll
#2  0x000000018010645f in pinfo::wait() () from /usr/bin/cygwin1.dll
#3  0x000000018012e562 in proc_subproc(unsigned int, unsigned long) () from /usr/bin/cygwin1.dll
#4  0x0000000180134e85 in child_info_spawn::worker(char const*, char const* const*, char const* const*, int, int, int) () from /usr/bin/cygwin1.dll
#5  0x0000000180136729 in spawnve () from /usr/bin/cygwin1.dll
#6  0x0000000180136d05 in spawnvp () from /usr/bin/cygwin1.dll
#7  0x0000000180144683 in system () from /usr/bin/cygwin1.dll
#8  0x000000018018effb in _sigfe () from /usr/bin/cygwin1.dll
#9  0x000000010052884b in QMachine__ExecCommand (t_L_563=0x448ef0 "\260\324\005",

'cause i.e. it complicates any lifetime/management.
I do understand some of the problems here, like needing separate threads to read stdout/stderr, if they are not equal.

 - Jay

________________________________
From: Jay K
Sent: Wednesday, January 12, 2022 4:12 AM
To: cygwin@sourceware.org <cygwin@sourceware.org>
Subject: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6

I get this a lot:

      0 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    452 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    716 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
   1652 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
      0 [main] sh 7775 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?

Scenario is multi-threaded "launching" a bunch of invocations of gcc.
"launching" was usually spawnve or fork/execve but I changed the code to use system and it still happens.
I might try to make a small reproducing, if this is not known.
It seems a bit difficult to believe I could cause this internal looking error.

Thank you,
 - Jay

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

* Re:  proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-12  5:57 ` Jay K
@ 2022-01-12  6:27   ` Jay K
  2022-01-12  6:41     ` Marco Atzeri
  2022-01-13  6:40     ` Jay K
  0 siblings, 2 replies; 9+ messages in thread
From: Jay K @ 2022-01-12  6:27 UTC (permalink / raw)
  To: cygwin

Ok, here is a small demonstration of the problem.

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>

unsigned __stdcall thread(void* p)
{
  unsigned i;
  for (i = 0; i < 100; ++i)
   system("./a.exe");
  return 0;
}

int main()
{
unsigned i;
HANDLE threads[100] = {0};
FILE* f = fopen("a.c", "w");
fprintf(f, "int main() { return 0; }\n");
fclose(f);

system("g++ a.c");

for (i = 0; i < 100; ++i)
 threads[i] = CreateThread(0, 0, thread, 0,0,0);

for (i = 0; i < 100; ++i)
 WaitForSingleObject(threads[i], -1);

}

$ ./1.exe
      0 [main] sh 9287 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?
                                                  3001 [main] sh 9287 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
                                                       0 [main] sh 9286 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?
                                                                                                Stack trace:
Frame        Function    Args
000FFFFCD30  00180061C6E (001802795F0, 00180269E81, 00000000000, 000FFFFBB20)
000FFFFCD30  0018004849A (00000000228, 00800000160, 00000000000, 000FFFFCD30)
000FFFFCD30  001800484D2 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFCD30  0018005F12D (00180158C19, 00000000000, 00000000000, 000FFFFCD30)
000FFFFCD30  00180103AE4 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFCD30  00180048BC2 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  00180047746 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  001800477F4 (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace
                        0 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
             1078 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
     4452 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                            sh: ./a.exe: Bad address
  11522 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                          sh: ./a.exe: Bad address
sh: ./a.exe: Bad address
  38623 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                            48009 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                    48660 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                            49909 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6


I understand I can workaround this, in that the use of threads is silly.

Is this invalid, to mix Win32 threads with cygwin system()?

 - Jay

________________________________
From: Jay K <jayk123@hotmail.com>
Sent: Wednesday, January 12, 2022 5:57 AM
To: cygwin@sourceware.org <cygwin@sourceware.org>
Subject: Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6

Um, I know this isn't (yet) diligent/scientific, but must system create this thread?

#0  0x00007ff811e09e47 in KERNEL32!CreateThread () from /cygdrive/c/WINDOWS/System32/KERNEL32.DLL
#1  0x00000001800468eb in cygthread::create() () from /usr/bin/cygwin1.dll
#2  0x000000018010645f in pinfo::wait() () from /usr/bin/cygwin1.dll
#3  0x000000018012e562 in proc_subproc(unsigned int, unsigned long) () from /usr/bin/cygwin1.dll
#4  0x0000000180134e85 in child_info_spawn::worker(char const*, char const* const*, char const* const*, int, int, int) () from /usr/bin/cygwin1.dll
#5  0x0000000180136729 in spawnve () from /usr/bin/cygwin1.dll
#6  0x0000000180136d05 in spawnvp () from /usr/bin/cygwin1.dll
#7  0x0000000180144683 in system () from /usr/bin/cygwin1.dll
#8  0x000000018018effb in _sigfe () from /usr/bin/cygwin1.dll
#9  0x000000010052884b in QMachine__ExecCommand (t_L_563=0x448ef0 "\260\324\005",

'cause i.e. it complicates any lifetime/management.
I do understand some of the problems here, like needing separate threads to read stdout/stderr, if they are not equal.

 - Jay

________________________________
From: Jay K
Sent: Wednesday, January 12, 2022 4:12 AM
To: cygwin@sourceware.org <cygwin@sourceware.org>
Subject: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6

I get this a lot:

      0 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    452 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    716 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
   1652 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
      0 [main] sh 7775 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?

Scenario is multi-threaded "launching" a bunch of invocations of gcc.
"launching" was usually spawnve or fork/execve but I changed the code to use system and it still happens.
I might try to make a small reproducing, if this is not known.
It seems a bit difficult to believe I could cause this internal looking error.

Thank you,
 - Jay

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

* Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-12  6:27   ` Jay K
@ 2022-01-12  6:41     ` Marco Atzeri
  2022-01-13 23:52       ` Takashi Yano
  2022-01-13  6:40     ` Jay K
  1 sibling, 1 reply; 9+ messages in thread
From: Marco Atzeri @ 2022-01-12  6:41 UTC (permalink / raw)
  To: cygwin

On 12.01.2022 07:27, Jay K wrote:
> Ok, here is a small demonstration of the problem.
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <windows.h>
> 
> unsigned __stdcall thread(void* p)
> {
>    unsigned i;
>    for (i = 0; i < 100; ++i)
>     system("./a.exe");
>    return 0;
> }
> 
> int main()
> {
> unsigned i;
> HANDLE threads[100] = {0};
> FILE* f = fopen("a.c", "w");
> fprintf(f, "int main() { return 0; }\n");
> fclose(f);


so you are mixing Cygwin and Windows calls ?
That is looking for trouble.

Or it is a tentative to produce a test case ?

Regards
Marco


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

* Re:  proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-12  6:27   ` Jay K
  2022-01-12  6:41     ` Marco Atzeri
@ 2022-01-13  6:40     ` Jay K
  2022-01-13 13:42       ` Eliot Moss
  1 sibling, 1 reply; 9+ messages in thread
From: Jay K @ 2022-01-13  6:40 UTC (permalink / raw)
  To: cygwin

I don't know why I didn't get the reply in email, but this is representative of the real world code.

 - Jay


From: Jay K <jayk123@hotmail.com>
Sent: Wednesday, January 12, 2022 6:27 AM
To: cygwin@sourceware.org <cygwin@sourceware.org>
Subject: Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 
 
Ok, here is a small demonstration of the problem.

#include <stdlib.h> 
#include <stdio.h>
#include <windows.h>

unsigned __stdcall thread(void* p)
{
  unsigned i;
  for (i = 0; i < 100; ++i)
   system("./a.exe");
  return 0;
}

int main()
{
unsigned i;
HANDLE threads[100] = {0};
FILE* f = fopen("a.c", "w");
fprintf(f, "int main() { return 0; }\n");
fclose(f);

system("g++ a.c");

for (i = 0; i < 100; ++i)
 threads[i] = CreateThread(0, 0, thread, 0,0,0);

for (i = 0; i < 100; ++i)
 WaitForSingleObject(threads[i], -1);

}

$ ./1.exe 
      0 [main] sh 9287 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?
                                                  3001 [main] sh 9287 cygwin_exception::open_stackdumpfile: Dumping stack trace to sh.exe.stackdump
                                                       0 [main] sh 9286 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?
                                                                                                Stack trace:
Frame        Function    Args
000FFFFCD30  00180061C6E (001802795F0, 00180269E81, 00000000000, 000FFFFBB20)
000FFFFCD30  0018004849A (00000000228, 00800000160, 00000000000, 000FFFFCD30)
000FFFFCD30  001800484D2 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFCD30  0018005F12D (00180158C19, 00000000000, 00000000000, 000FFFFCD30)
000FFFFCD30  00180103AE4 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFCD30  00180048BC2 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  00180047746 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0  001800477F4 (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace
                        0 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
             1078 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
     4452 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                            sh: ./a.exe: Bad address
  11522 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                          sh: ./a.exe: Bad address
sh: ./a.exe: Bad address
  38623 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                            48009 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                                    48660 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
                                                                            49909 [waitproc] 1 9269 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6


I understand I can workaround this, in that the use of threads is silly.

Is this invalid, to mix Win32 threads with cygwin system()?

 - Jay


From: Jay K <jayk123@hotmail.com>
Sent: Wednesday, January 12, 2022 5:57 AM
To: cygwin@sourceware.org <cygwin@sourceware.org>
Subject: Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 
 
Um, I know this isn't (yet) diligent/scientific, but must system create this thread?

#0  0x00007ff811e09e47 in KERNEL32!CreateThread () from /cygdrive/c/WINDOWS/System32/KERNEL32.DLL 
#1  0x00000001800468eb in cygthread::create() () from /usr/bin/cygwin1.dll
#2  0x000000018010645f in pinfo::wait() () from /usr/bin/cygwin1.dll
#3  0x000000018012e562 in proc_subproc(unsigned int, unsigned long) () from /usr/bin/cygwin1.dll
#4  0x0000000180134e85 in child_info_spawn::worker(char const*, char const* const*, char const* const*, int, int, int) () from /usr/bin/cygwin1.dll
#5  0x0000000180136729 in spawnve () from /usr/bin/cygwin1.dll
#6  0x0000000180136d05 in spawnvp () from /usr/bin/cygwin1.dll
#7  0x0000000180144683 in system () from /usr/bin/cygwin1.dll
#8  0x000000018018effb in _sigfe () from /usr/bin/cygwin1.dll
#9  0x000000010052884b in QMachine__ExecCommand (t_L_563=0x448ef0 "\260\324\005",

'cause i.e. it complicates any lifetime/management.
I do understand some of the problems here, like needing separate threads to read stdout/stderr, if they are not equal.

 - Jay


From: Jay K
Sent: Wednesday, January 12, 2022 4:12 AM
To: cygwin@sourceware.org <cygwin@sourceware.org>
Subject: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 
 
I get this a lot:

      0 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    452 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
    716 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
   1652 [waitproc] cm3 7641 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
      0 [main] sh 7775 C:\cygwin64\bin\sh.exe: *** fatal error - internal error reading the windows environment - too many environment variables?
 
Scenario is multi-threaded "launching" a bunch of invocations of gcc.
"launching" was usually spawnve or fork/execve but I changed the code to use system and it still happens.
I might try to make a small reproducing, if this is not known.
It seems a bit difficult to believe I could cause this internal looking error.

Thank you,
 - Jay

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

* Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-13  6:40     ` Jay K
@ 2022-01-13 13:42       ` Eliot Moss
  0 siblings, 0 replies; 9+ messages in thread
From: Eliot Moss @ 2022-01-13 13:42 UTC (permalink / raw)
  To: Jay K, cygwin

On 1/13/2022 1:40 AM, Jay K wrote:
> I don't know why I didn't get the reply in email, but this is representative of the real world code.
> 
>   - Jay
> 
> 
> From: Jay K <jayk123@hotmail.com>
> Sent: Wednesday, January 12, 2022 6:27 AM
> To: cygwin@sourceware.org <cygwin@sourceware.org>
> Subject: Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
>   
> Ok, here is a small demonstration of the problem.
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <windows.h>
> 
> unsigned __stdcall thread(void* p)
> {
>    unsigned i;
>    for (i = 0; i < 100; ++i)
>     system("./a.exe");
>    return 0;
> }
> 
> int main()
> {
> unsigned i;
> HANDLE threads[100] = {0};
> FILE* f = fopen("a.c", "w");
> fprintf(f, "int main() { return 0; }\n");
> fclose(f);
> 
> system("g++ a.c");
> 
> for (i = 0; i < 100; ++i)
>   threads[i] = CreateThread(0, 0, thread, 0,0,0);
> 
> for (i = 0; i < 100; ++i)
>   WaitForSingleObject(threads[i], -1);
> 
> }

Again, Cygwin is designed to provide a POSIX-like interface.
Maybe you should just be using a Windows C compiler?

EM

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

* Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-12  6:41     ` Marco Atzeri
@ 2022-01-13 23:52       ` Takashi Yano
  2022-01-14  0:11         ` Mark Geisert
  0 siblings, 1 reply; 9+ messages in thread
From: Takashi Yano @ 2022-01-13 23:52 UTC (permalink / raw)
  To: cygwin

On Wed, 12 Jan 2022 07:41:41 +0100
Marco Atzeri wrote:
> On 12.01.2022 07:27, Jay K wrote:
> > Ok, here is a small demonstration of the problem.
> > 
> > #include <stdlib.h>
> > #include <stdio.h>
> > #include <windows.h>
> > 
> > unsigned __stdcall thread(void* p)
> > {
> >    unsigned i;
> >    for (i = 0; i < 100; ++i)
> >     system("./a.exe");
> >    return 0;
> > }
> > 
> > int main()
> > {
> > unsigned i;
> > HANDLE threads[100] = {0};
> > FILE* f = fopen("a.c", "w");
> > fprintf(f, "int main() { return 0; }\n");
> > fclose(f);
> 
> 
> so you are mixing Cygwin and Windows calls ?
> That is looking for trouble.
> 
> Or it is a tentative to produce a test case ?

I found that the same happens even with pthread rather than
win32 thread functions.

#include <stdlib.h>
#include <pthread.h>

void *thread(void *p)
{
	system("true");
	return NULL;
}

int main()
{
	int i;
	pthread_t threads[2];

	for (i = 0; i < 2; i++)
		pthread_create(&threads[i], NULL, thread, NULL);

	for (i = 0; i < 2; i++)
		pthread_join(threads[i], NULL);

	return 0;
}

Executing above code results in hang with message:
      0 [waitproc] a 786 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

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

* Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-13 23:52       ` Takashi Yano
@ 2022-01-14  0:11         ` Mark Geisert
  2022-01-14  0:22           ` Takashi Yano
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Geisert @ 2022-01-14  0:11 UTC (permalink / raw)
  To: cygwin

Takashi Yano wrote:
> On Wed, 12 Jan 2022 07:41:41 +0100
> Marco Atzeri wrote:
>> On 12.01.2022 07:27, Jay K wrote:
>>> Ok, here is a small demonstration of the problem.
>>>
>>> #include <stdlib.h>
>>> #include <stdio.h>
>>> #include <windows.h>
>>>
>>> unsigned __stdcall thread(void* p)
>>> {
>>>     unsigned i;
>>>     for (i = 0; i < 100; ++i)
>>>      system("./a.exe");
>>>     return 0;
>>> }
>>>
>>> int main()
>>> {
>>> unsigned i;
>>> HANDLE threads[100] = {0};
>>> FILE* f = fopen("a.c", "w");
>>> fprintf(f, "int main() { return 0; }\n");
>>> fclose(f);
>>
>>
>> so you are mixing Cygwin and Windows calls ?
>> That is looking for trouble.
>>
>> Or it is a tentative to produce a test case ?
> 
> I found that the same happens even with pthread rather than
> win32 thread functions.
> 
> #include <stdlib.h>
> #include <pthread.h>
> 
> void *thread(void *p)
> {
> 	system("true");
> 	return NULL;
> }
> 
> int main()
> {
> 	int i;
> 	pthread_t threads[2];
> 
> 	for (i = 0; i < 2; i++)
> 		pthread_create(&threads[i], NULL, thread, NULL);
> 
> 	for (i = 0; i < 2; i++)
> 		pthread_join(threads[i], NULL);
> 
> 	return 0;
> }
> 
> Executing above code results in hang with message:
>        0 [waitproc] a 786 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
> 

POSIX does not require system() to be thread-safe.  On Cygwin, it isn't.  When I 
ran into this a while back, I implemented an application wrapper around system() 
to serialize calls.  It's tricky because you want to serialize just the mechanism 
of system(), not the programs that the multiple system()s call.

..mark


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

* Re: proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
  2022-01-14  0:11         ` Mark Geisert
@ 2022-01-14  0:22           ` Takashi Yano
  0 siblings, 0 replies; 9+ messages in thread
From: Takashi Yano @ 2022-01-14  0:22 UTC (permalink / raw)
  To: cygwin

On Thu, 13 Jan 2022 16:11:04 -0800
Mark Geisert wrote:
> Takashi Yano wrote:
> > On Wed, 12 Jan 2022 07:41:41 +0100
> > Marco Atzeri wrote:
> >> On 12.01.2022 07:27, Jay K wrote:
> >>> Ok, here is a small demonstration of the problem.
> >>>
> >>> #include <stdlib.h>
> >>> #include <stdio.h>
> >>> #include <windows.h>
> >>>
> >>> unsigned __stdcall thread(void* p)
> >>> {
> >>>     unsigned i;
> >>>     for (i = 0; i < 100; ++i)
> >>>      system("./a.exe");
> >>>     return 0;
> >>> }
> >>>
> >>> int main()
> >>> {
> >>> unsigned i;
> >>> HANDLE threads[100] = {0};
> >>> FILE* f = fopen("a.c", "w");
> >>> fprintf(f, "int main() { return 0; }\n");
> >>> fclose(f);
> >>
> >>
> >> so you are mixing Cygwin and Windows calls ?
> >> That is looking for trouble.
> >>
> >> Or it is a tentative to produce a test case ?
> > 
> > I found that the same happens even with pthread rather than
> > win32 thread functions.
> > 
> > #include <stdlib.h>
> > #include <pthread.h>
> > 
> > void *thread(void *p)
> > {
> > 	system("true");
> > 	return NULL;
> > }
> > 
> > int main()
> > {
> > 	int i;
> > 	pthread_t threads[2];
> > 
> > 	for (i = 0; i < 2; i++)
> > 		pthread_create(&threads[i], NULL, thread, NULL);
> > 
> > 	for (i = 0; i < 2; i++)
> > 		pthread_join(threads[i], NULL);
> > 
> > 	return 0;
> > }
> > 
> > Executing above code results in hang with message:
> >        0 [waitproc] a 786 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6
> > 
> 
> POSIX does not require system() to be thread-safe.  On Cygwin, it isn't.  When I 
> ran into this a while back, I implemented an application wrapper around system() 
> to serialize calls.  It's tricky because you want to serialize just the mechanism 
> of system(), not the programs that the multiple system()s call.

Ah, indeed.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html
says:
  "The system() function need not be thread-safe."
while Linux's system() is MT-safe.

Thanks.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

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

end of thread, other threads:[~2022-01-14  0:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12  4:12 proc_waiter: error on read of child wait pipe 0x0, Win32 error 6 Jay K
2022-01-12  5:57 ` Jay K
2022-01-12  6:27   ` Jay K
2022-01-12  6:41     ` Marco Atzeri
2022-01-13 23:52       ` Takashi Yano
2022-01-14  0:11         ` Mark Geisert
2022-01-14  0:22           ` Takashi Yano
2022-01-13  6:40     ` Jay K
2022-01-13 13:42       ` Eliot Moss

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).