fork: Resource temporarily unavailable errors after upgrading cygwin packages

classic Classic list List threaded Threaded
31 messages Options
12
pdt
Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

pdt
Hi Takashi,

Thanks for looking at this & your great work on Cygwin!

On Tue, 2020-02-11 at 11:20 +0900, Takashi Yano wrote:
> Is this the same as your problem?

Yeah, it could be. Could this result in fork error messages as we are
seeing all over the place?

> If so, it goes without stopping 1 minute with patch:
> https://cygwin.com/ml/cygwin-patches/2020-q1/msg00148.html

Nice trick to use pinfo as a work-around, but i could fear that others
also call kill() at this critical time. Is there an actual fix for
kill() in the cooking? I could fear that tools like "make" actually
call this all over the place, especially if its aborting running
processes. And why did this work before?

> In any case, the following error occurs.
>
> /usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../x86_64-pc-
> cygwin/bin/ld:test00.d: file format not recognized; treating as
> linker script

That looks OK. Ignore the actual result of the makefile,
its just garbage :-). Its only to reproduce this error.

Thanks again for helping,

/pedro


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

pdt
Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

pdt
On Tue, 2020-02-11 at 11:38 +0100, Peter Dons Tychsen wrote:
> processes. And why did this work before?

And why does it work when running without minnty? How does that play
into this?

Thanks,

/pedro


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

Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

Takashi Yano
In reply to this post by pdt
On Tue, 11 Feb 2020 11:38:35 +0100
Peter Dons Tychsen wrote:
> On Tue, 2020-02-11 at 11:20 +0900, Takashi Yano wrote:
> > Is this the same as your problem?
>
> Yeah, it could be. Could this result in fork error messages as we are
> seeing all over the place?

No. Fork error is not seen in my environment. This could be another
problem. However, the code using kill() below is called also by fork().
So, it may be related.

I have not investigated your problem on make, so the mechanism to
cause the problem is not clear. I do not have confidence that this
patch really fixes your problem.

> > If so, it goes without stopping 1 minute with patch:
> > https://cygwin.com/ml/cygwin-patches/2020-q1/msg00148.html
>
> Nice trick to use pinfo as a work-around, but i could fear that others
> also call kill() at this critical time. Is there an actual fix for
> kill() in the cooking? I could fear that tools like "make" actually
> call this all over the place, especially if its aborting running
> processes. And why did this work before?

The commit message says:
>  This seems to be caused by invalid pointer access which occurs
>  when the process exits during the kill() code is execuetd. This
>  patch avoids the issue by not using kill().
however, I found the real cause is that errno is accidentally set
by kill() in pty system calls. That is, the problem is not in the
kill() itself but in usage of it. Cygwin older than 3.1.0 does not
have these code in pty.

On Tue, 11 Feb 2020 11:40:45 +0100
Peter Dons Tychsen wrote:
> And why does it work when running without minnty? How does that play
> into this?

The code which has this problem is in the pty code. So, this occurs
only in pty such as mintty, xterm, etc. Console (cygwin in command
prompt) does not use pty, so problem does not occur in console.

--
Takashi Yano <[hidden email]>

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

Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

Ken Brown-6
On 2/11/2020 8:16 AM, Takashi Yano wrote:

> On Tue, 11 Feb 2020 11:38:35 +0100
> Peter Dons Tychsen wrote:
>> On Tue, 2020-02-11 at 11:20 +0900, Takashi Yano wrote:
>>> Is this the same as your problem?
>>
>> Yeah, it could be. Could this result in fork error messages as we are
>> seeing all over the place?
>
> No. Fork error is not seen in my environment. This could be another
> problem. However, the code using kill() below is called also by fork().
> So, it may be related.

FWIW, I'm not seeing the fork error in my environment either.  I see the hang
prior to your kill() patch, and then no problem (except for the ld error).

Ken

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

pdt
Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

pdt
In reply to this post by Takashi Yano
Hi Takashi,

Thanks for your effort.

On Tue, 2020-02-11 at 22:16 +0900, Takashi Yano wrote:
> however, I found the real cause is that errno is accidentally set
> by kill() in pty system calls. That is, the problem is not in the
> kill() itself but in usage of it. Cygwin older than 3.1.0 does not
> have these code in pty.

OK, is there a fix for that or is that the fix you already pushed? And
what is wrong with the usage of kill(). How can kill() be used
incorrectly?

Is there are more things here it would be great to get them in for the
3.1.3 release.

Thanks,

/pedro


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

Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

Takashi Yano
On Tue, 11 Feb 2020 22:31:12 +0100
Peter Dons Tychsen wrote:
> On Tue, 2020-02-11 at 22:16 +0900, Takashi Yano wrote:
> > however, I found the real cause is that errno is accidentally set
> > by kill() in pty system calls. That is, the problem is not in the
> > kill() itself but in usage of it. Cygwin older than 3.1.0 does not
> > have these code in pty.
>
> OK, is there a fix for that or is that the fix you already pushed? And
> what is wrong with the usage of kill(). How can kill() be used
> incorrectly?

POSIX system calls set global variable errno to appropriate
value when the system calls fail.
http://man7.org/linux/man-pages/man3/errno.3.html

My failure in pty code was that I used kill() in pty system
calls. kill() can be used check if the process is still alive
by passing signal number of 0 to the second argument. It returns
-1 if the process already exited. However, in this case errno
is set to ESRCH. As a result, the errno value which pty system
call set is accidentally overwritten by kill().

The patch was already accepted and pushed to git repository.
I hope cygwin 3.1.3 which applied this patch will be released
shortly.

--
Takashi Yano <[hidden email]>

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

Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

Corinna Vinschen-2
On Feb 12 11:24, Takashi Yano wrote:

> On Tue, 11 Feb 2020 22:31:12 +0100
> Peter Dons Tychsen wrote:
> > On Tue, 2020-02-11 at 22:16 +0900, Takashi Yano wrote:
> > > however, I found the real cause is that errno is accidentally set
> > > by kill() in pty system calls. That is, the problem is not in the
> > > kill() itself but in usage of it. Cygwin older than 3.1.0 does not
> > > have these code in pty.
> >
> > OK, is there a fix for that or is that the fix you already pushed? And
> > what is wrong with the usage of kill(). How can kill() be used
> > incorrectly?
>
> POSIX system calls set global variable errno to appropriate
> value when the system calls fail.
> http://man7.org/linux/man-pages/man3/errno.3.html
>
> My failure in pty code was that I used kill() in pty system
> calls. kill() can be used check if the process is still alive
> by passing signal number of 0 to the second argument. It returns
> -1 if the process already exited. However, in this case errno
> is set to ESRCH. As a result, the errno value which pty system
> call set is accidentally overwritten by kill().
>
> The patch was already accepted and pushed to git repository.
> I hope cygwin 3.1.3 which applied this patch will be released
> shortly.
For a first test, please try the latest developer snapshot on
https://cygwin.com/snapshots/


Thanks,
Corinna

--
Corinna Vinschen
Cygwin Maintainer

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

Takashi Yano
In reply to this post by Ken Brown-6
On Tue, 11 Feb 2020 09:21:32 -0500
Ken Brown wrote:

> On 2/11/2020 8:16 AM, Takashi Yano wrote:
> > On Tue, 11 Feb 2020 11:38:35 +0100
> > Peter Dons Tychsen wrote:
> >> On Tue, 2020-02-11 at 11:20 +0900, Takashi Yano wrote:
> >>> Is this the same as your problem?
> >>
> >> Yeah, it could be. Could this result in fork error messages as we are
> >> seeing all over the place?
> >
> > No. Fork error is not seen in my environment. This could be another
> > problem. However, the code using kill() below is called also by fork().
> > So, it may be related.
>
> FWIW, I'm not seeing the fork error in my environment either.  I see the hang
> prior to your kill() patch, and then no problem (except for the ld error).

I tested under Win10 1809 and found fork error occurs in that
environment. Also confirmed the kill() patch fixes the issue.

--
Takashi Yano <[hidden email]>

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

Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

Takashi Yano
In reply to this post by pdt
On Wed, 12 Feb 2020 11:54:02 +0100
Peter Dons Tychsen wrote:

> Hi Takashi,
>
> On Wed, 2020-02-12 at 11:24 +0900, Takashi Yano wrote:
> > My failure in pty code was that I used kill() in pty system
> > calls. kill() can be used check if the process is still alive
> > by passing signal number of 0 to the second argument. It returns
> > -1 if the process already exited. However, in this case errno
> > is set to ESRCH. As a result, the errno value which pty system
> > call set is accidentally overwritten by kill().
>
> OK, thanks for clearing all that up. Just wanted to make sure kill()
> was not buggy :-).
>
> I will test the committed patch and the upcoming release vigerously to
> see if there are still bugs to be found in this area. Not sure why i
> get fork() errors and you do not (my tests with the example i made
> always causes fork() errors in 3.1.2).
>
> Thanks for all the help and your snappy replies,

Could you please try latest snapshot?
https://cygwin.com/snapshots/

--
Takashi Yano <[hidden email]>

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

pdt
Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

pdt
Hi Takashi,

On Thu, 2020-02-13 at 13:13 +0900, Takashi Yano wrote:
> Could you please try latest snapshot?
> https://cygwin.com/snapshots/

The commit regarding use of kill() does the trick.
It's a go from here :-).

Thanks for all the help,

/pedro


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

Reply | Threaded
Open this post in threaded view
|

Re: fork: Resource temporarily unavailable errors after upgrading cygwin packages

Takashi Yano
On Thu, 13 Feb 2020 22:42:31 +0100
Peter Dons Tychsen wrote:
> On Thu, 2020-02-13 at 13:13 +0900, Takashi Yano wrote:
> > Could you please try latest snapshot?
> > https://cygwin.com/snapshots/
>
> The commit regarding use of kill() does the trick.
> It's a go from here :-).
>
> Thanks for all the help,

Thanks for testing.

I had looked into the make problem further, and found this
was not caused by the errno overwriting, but by calling
sig_dispatch_pending() in fixup_after_exec() via kill().

fixup_after_exec() is called from dll_crt0_0(). It seems
that calling sig_dispatch_pending() from dll_crl0_0()
causes hangs everywhere (even outside PTY).

I am not sure what exactly does sig_dispatch_pending()
and why this causes the problem, anyway, using pinfo()
rather than kill() solves the issue.

Thanks.

--
Takashi Yano <[hidden email]>

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

12