* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
@ 2022-01-25 6:48 Saulius Menkevicius
2022-01-25 8:41 ` Eli Zaretskii
2022-01-25 13:15 ` master 2c79a8f 2/2: Use posix_spawn if possible Stefan Monnier
0 siblings, 2 replies; 39+ messages in thread
From: Saulius Menkevicius @ 2022-01-25 6:48 UTC (permalink / raw)
To: emacs-devel; +Cc: p.stephani2, alan, mituharu
Hi,
I know this has been merged a couple of months ago to `master` but I
would like to report breakage that occurs due to that commit.
We have csharp-ls (C#) and fsautocomplete (F#) LSP servers that stopped
working with that commit (git-bisected to
a60053f8368e058229721f1bf1567c2b1676b239).
I did not delve too much into the details or prepare a minimal test case
but this appears to be an interplay between dotnet runtime (v6) and
posix_spawn.
Not sure if that warrants a revert but just a heads-up.
-Saulius
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 6:48 master 2c79a8f 2/2: Use posix_spawn if possible Saulius Menkevicius
@ 2022-01-25 8:41 ` Eli Zaretskii
2022-01-25 8:58 ` Saulius Menkevicius
2022-01-25 13:15 ` master 2c79a8f 2/2: Use posix_spawn if possible Stefan Monnier
1 sibling, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-01-25 8:41 UTC (permalink / raw)
To: emacs-devel, Saulius Menkevicius; +Cc: p.stephani2, alan, mituharu
On January 25, 2022 8:48:12 AM GMT+02:00, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> wrote:
> Hi,
>
> I know this has been merged a couple of months ago to `master` but I
> would like to report breakage that occurs due to that commit.
>
> We have csharp-ls (C#) and fsautocomplete (F#) LSP servers that stopped
> working with that commit (git-bisected to
> a60053f8368e058229721f1bf1567c2b1676b239).
>
> I did not delve too much into the details or prepare a minimal test case
> but this appears to be an interplay between dotnet runtime (v6) and
> posix_spawn.
>
> Not sure if that warrants a revert but just a heads-up.
Can you explain how dotnet runtime comes into play here? Does Emacs invoke a dotnet process or something?
And on what OS does this happen?
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 8:41 ` Eli Zaretskii
@ 2022-01-25 8:58 ` Saulius Menkevicius
2022-01-25 11:46 ` Jostein Kjønigsen
2022-01-25 12:22 ` Eli Zaretskii
0 siblings, 2 replies; 39+ messages in thread
From: Saulius Menkevicius @ 2022-01-25 8:58 UTC (permalink / raw)
To: Eli Zaretskii, emacs-devel; +Cc: p.stephani2, alan, mituharu
Sorry I did not mention the platform, this happens on Linux/x64 and has
been reported by multiple persons:
- https://github.com/razzmatazz/csharp-language-server/issues/12
The issue has been noticed when dotnet-based LSP servers are used with
emacs/lsp-mode, -- in particular lsp-mode starts the server using
`make-process` and then communicates over stdio. Link to the code that
launches the server:
- https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6925
We have csharp-ls and fsac servers launched with the same mechanism as
are for other languages -- which are working ok with posix_spawn
enabled. It only breaks for those before-mentioned LSP servers that are
implemented on top of dotnet and use dotnet runtime (same thing as JVM,
but for C#/F#/CLR languages).
Now it appears, that switch to posix_spawn broke communication over
stdio to those dotnet-based LSP servers for some technical reason, -- I
didn't investigate yet why, because it is a bit over my head. I *think*
there is an interplay between posix_spawn-based process launch
implementation in emacs and dotnet runtime stdio abstractions/platform
layer -- because otherwise other language servers work with that commit
that enables posix_spawn, like those based on JVM too.
I know this is a bit of a corner case as posix_spawn brings performance
benefits, but just FYI.
BR,
-Saulius Menkevicius
Am 25.01.22 um 10:41 schrieb Eli Zaretskii:
> On January 25, 2022 8:48:12 AM GMT+02:00, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> wrote:
>> Hi,
>>
>> I know this has been merged a couple of months ago to `master` but I
>> would like to report breakage that occurs due to that commit.
>>
>> We have csharp-ls (C#) and fsautocomplete (F#) LSP servers that stopped
>> working with that commit (git-bisected to
>> a60053f8368e058229721f1bf1567c2b1676b239).
>>
>> I did not delve too much into the details or prepare a minimal test case
>> but this appears to be an interplay between dotnet runtime (v6) and
>> posix_spawn.
>>
>> Not sure if that warrants a revert but just a heads-up.
> Can you explain how dotnet runtime comes into play here? Does Emacs invoke a dotnet process or something?
>
> And on what OS does this happen?
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 8:58 ` Saulius Menkevicius
@ 2022-01-25 11:46 ` Jostein Kjønigsen
2022-01-25 11:55 ` Po Lu
2022-01-25 12:22 ` Eli Zaretskii
1 sibling, 1 reply; 39+ messages in thread
From: Jostein Kjønigsen @ 2022-01-25 11:46 UTC (permalink / raw)
To: emacs-devel, Eli Zaretskii; +Cc: Saulius Menkevičius
[-- Attachment #1: Type: text/plain, Size: 3522 bytes --]
Like Saulius says, this is fairly technical and far above at least my head.
I still think it's worth discussing if we *need* this change for Linux.
When the original commit was landed, (from what I can tell) it was
because it was needed for Mac, and assumed harmless for other platforms.
The merge to master was then meant as a testing-ground to see if it
would cause issues.
And well.. Here's at least one issue :)
For perspective, over the last couple of years, Emacs as a
editor/platform to work with .NET has improved tremendously to the point
that Emacs is my primary editor for anything .NET. It would be a shame
to see that completely break on Emacs 29, and being forced to use VSCode
to get work done.
As things stand now, I think it sounds easier to revert this change (for
Linux only) than trying to convince Microsoft to change the .NET runtime
to better interop with Emacs on Linux :)
My 2 cents.
--
Kind regards
Jostein Kjønigsen
On 25.01.2022 09:58, Saulius Menkevicius wrote:
> Sorry I did not mention the platform, this happens on Linux/x64 and
> has been reported by multiple persons:
>
> - https://github.com/razzmatazz/csharp-language-server/issues/12
>
>
> The issue has been noticed when dotnet-based LSP servers are used with
> emacs/lsp-mode, -- in particular lsp-mode starts the server using
> `make-process` and then communicates over stdio. Link to the code that
> launches the server:
>
> - https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6925
>
>
> We have csharp-ls and fsac servers launched with the same mechanism as
> are for other languages -- which are working ok with posix_spawn
> enabled. It only breaks for those before-mentioned LSP servers that
> are implemented on top of dotnet and use dotnet runtime (same thing as
> JVM, but for C#/F#/CLR languages).
>
> Now it appears, that switch to posix_spawn broke communication over
> stdio to those dotnet-based LSP servers for some technical reason, --
> I didn't investigate yet why, because it is a bit over my head. I
> *think* there is an interplay between posix_spawn-based process launch
> implementation in emacs and dotnet runtime stdio abstractions/platform
> layer -- because otherwise other language servers work with that
> commit that enables posix_spawn, like those based on JVM too.
>
>
> I know this is a bit of a corner case as posix_spawn brings
> performance benefits, but just FYI.
>
> BR,
>
> -Saulius Menkevicius
>
>
> Am 25.01.22 um 10:41 schrieb Eli Zaretskii:
>> On January 25, 2022 8:48:12 AM GMT+02:00, Saulius Menkevicius
>> <sauliusmenkevicius@fastmail.com> wrote:
>>> Hi,
>>>
>>> I know this has been merged a couple of months ago to `master` but I
>>> would like to report breakage that occurs due to that commit.
>>>
>>> We have csharp-ls (C#) and fsautocomplete (F#) LSP servers that stopped
>>> working with that commit (git-bisected to
>>> a60053f8368e058229721f1bf1567c2b1676b239).
>>>
>>> I did not delve too much into the details or prepare a minimal test
>>> case
>>> but this appears to be an interplay between dotnet runtime (v6) and
>>> posix_spawn.
>>>
>>> Not sure if that warrants a revert but just a heads-up.
>> Can you explain how dotnet runtime comes into play here? Does Emacs
>> invoke a dotnet process or something?
>>
>> And on what OS does this happen?
>
--
Vennlig hilsen
*Jostein Kjønigsen*
jostein@kjonigsen.net 🍵 jostein@gmail.com 🍵 jostein@hufleslufs.no
https://jostein.kjønigsen.no <https://jostein.kjønigsen.no>
[-- Attachment #2: Type: text/html, Size: 5451 bytes --]
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 11:46 ` Jostein Kjønigsen
@ 2022-01-25 11:55 ` Po Lu
0 siblings, 0 replies; 39+ messages in thread
From: Po Lu @ 2022-01-25 11:55 UTC (permalink / raw)
To: Jostein Kjønigsen
Cc: emacs-devel, Eli Zaretskii, jostein, Saulius Menkevičius
Jostein Kjønigsen <jostein@secure.kjonigsen.net> writes:
> Like Saulius says, this is fairly technical and far above at least my head.
>
> I still think it's worth discussing if we *need* this change for
> Linux. When the original commit was landed, (from what I can tell) it
> was because it was needed for Mac, and assumed harmless for other
> platforms. The merge to master was then meant as a testing-ground to
> see if it would cause issues.
FWIW, I think use of posix_spawn should only be enabled on macOS, as a
work around for Apple's recent changes to vfork. There is no reason to
risk needlessly breaking things for people.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 8:58 ` Saulius Menkevicius
2022-01-25 11:46 ` Jostein Kjønigsen
@ 2022-01-25 12:22 ` Eli Zaretskii
2022-01-25 12:25 ` Saulius Menkevicius
1 sibling, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-01-25 12:22 UTC (permalink / raw)
To: Saulius Menkevicius; +Cc: p.stephani2, alan, mituharu, emacs-devel
> Date: Tue, 25 Jan 2022 10:58:51 +0200
> Cc: p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp
> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
>
> Sorry I did not mention the platform, this happens on Linux/x64 and has
> been reported by multiple persons:
>
> - https://github.com/razzmatazz/csharp-language-server/issues/12
>
>
> The issue has been noticed when dotnet-based LSP servers are used with
> emacs/lsp-mode, -- in particular lsp-mode starts the server using
> `make-process` and then communicates over stdio. Link to the code that
> launches the server:
>
> - https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6925
>
>
> We have csharp-ls and fsac servers launched with the same mechanism as
> are for other languages -- which are working ok with posix_spawn
> enabled. It only breaks for those before-mentioned LSP servers that are
> implemented on top of dotnet and use dotnet runtime (same thing as JVM,
> but for C#/F#/CLR languages).
>
> Now it appears, that switch to posix_spawn broke communication over
> stdio to those dotnet-based LSP servers for some technical reason, -- I
> didn't investigate yet why, because it is a bit over my head. I *think*
> there is an interplay between posix_spawn-based process launch
> implementation in emacs and dotnet runtime stdio abstractions/platform
> layer -- because otherwise other language servers work with that commit
> that enables posix_spawn, like those based on JVM too.
What is special about dotnet's runtime stdio usage?
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 12:22 ` Eli Zaretskii
@ 2022-01-25 12:25 ` Saulius Menkevicius
2022-01-25 13:47 ` Eli Zaretskii
0 siblings, 1 reply; 39+ messages in thread
From: Saulius Menkevicius @ 2022-01-25 12:25 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: p.stephani2, alan, mituharu, emacs-devel
I certainly cannot answer that, it probably does some kind of sniffing
on FDs and changes behaviour.
To actually figure that out I would need to build a minimal test fixture
for this bug/issue and submit to dotnet/runtime repo on github for them
to check and/or fix it.
-Saulius
Am 25.01.22 um 14:22 schrieb Eli Zaretskii:
>> Date: Tue, 25 Jan 2022 10:58:51 +0200
>> Cc: p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp
>> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
>>
>> Sorry I did not mention the platform, this happens on Linux/x64 and has
>> been reported by multiple persons:
>>
>> - https://github.com/razzmatazz/csharp-language-server/issues/12
>>
>>
>> The issue has been noticed when dotnet-based LSP servers are used with
>> emacs/lsp-mode, -- in particular lsp-mode starts the server using
>> `make-process` and then communicates over stdio. Link to the code that
>> launches the server:
>>
>> - https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6925
>>
>>
>> We have csharp-ls and fsac servers launched with the same mechanism as
>> are for other languages -- which are working ok with posix_spawn
>> enabled. It only breaks for those before-mentioned LSP servers that are
>> implemented on top of dotnet and use dotnet runtime (same thing as JVM,
>> but for C#/F#/CLR languages).
>>
>> Now it appears, that switch to posix_spawn broke communication over
>> stdio to those dotnet-based LSP servers for some technical reason, -- I
>> didn't investigate yet why, because it is a bit over my head. I *think*
>> there is an interplay between posix_spawn-based process launch
>> implementation in emacs and dotnet runtime stdio abstractions/platform
>> layer -- because otherwise other language servers work with that commit
>> that enables posix_spawn, like those based on JVM too.
> What is special about dotnet's runtime stdio usage?
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 6:48 master 2c79a8f 2/2: Use posix_spawn if possible Saulius Menkevicius
2022-01-25 8:41 ` Eli Zaretskii
@ 2022-01-25 13:15 ` Stefan Monnier
1 sibling, 0 replies; 39+ messages in thread
From: Stefan Monnier @ 2022-01-25 13:15 UTC (permalink / raw)
To: Saulius Menkevicius; +Cc: emacs-devel, p.stephani2, alan, mituharu
> I know this has been merged a couple of months ago to `master` but I would
> like to report breakage that occurs due to that commit.
>
> We have csharp-ls (C#) and fsautocomplete (F#) LSP servers that stopped
> working with that commit (git-bisected to
> a60053f8368e058229721f1bf1567c2b1676b239).
>
> I did not delve too much into the details or prepare a minimal test case but
> this appears to be an interplay between dotnet runtime (v6) and posix_spawn.
>
> Not sure if that warrants a revert but just a heads-up.
Whatever may be decided w.r.t this, could you `M-x report-emacs-bug` so
we get a bug-nb for this problem?
[ And of course, please include as many details as possible about when/where
the bug shows up, and even ideally some kind of recipe, as usual. ]
Stefan
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 12:25 ` Saulius Menkevicius
@ 2022-01-25 13:47 ` Eli Zaretskii
2022-01-28 17:12 ` Matt Armstrong
0 siblings, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-01-25 13:47 UTC (permalink / raw)
To: Saulius Menkevicius; +Cc: p.stephani2, alan, mituharu, emacs-devel
> Date: Tue, 25 Jan 2022 14:25:23 +0200
> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
> Cc: p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
> emacs-devel@gnu.org
>
> I certainly cannot answer that, it probably does some kind of sniffing
> on FDs and changes behaviour.
>
> To actually figure that out I would need to build a minimal test fixture
> for this bug/issue and submit to dotnet/runtime repo on github for them
> to check and/or fix it.
I think there's no way around this. We need at least to understand
what part of posix_spawn code interferes with pipe-based I/O used by
these LSP servers, and why.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-25 13:47 ` Eli Zaretskii
@ 2022-01-28 17:12 ` Matt Armstrong
2022-01-29 8:03 ` Saulius Menkevičius
2022-01-29 8:26 ` Eli Zaretskii
0 siblings, 2 replies; 39+ messages in thread
From: Matt Armstrong @ 2022-01-28 17:12 UTC (permalink / raw)
To: Eli Zaretskii, Saulius Menkevicius
Cc: p.stephani2, alan, mituharu, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> Date: Tue, 25 Jan 2022 14:25:23 +0200
>> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
>> Cc: p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
>> emacs-devel@gnu.org
>>
>> I certainly cannot answer that, it probably does some kind of sniffing
>> on FDs and changes behaviour.
>>
>> To actually figure that out I would need to build a minimal test fixture
>> for this bug/issue and submit to dotnet/runtime repo on github for them
>> to check and/or fix it.
>
> I think there's no way around this. We need at least to understand
> what part of posix_spawn code interferes with pipe-based I/O used by
> these LSP servers, and why.
I don't find an emacs bug filed for this issue. Saulius, it would be
good to file one.
This issue tickled a memory I had of Python moving away from posix_spawn
due to various portability issues: https://bugs.python.org/issue35823.
The issues they ran into and solved may inform this investigation.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-28 17:12 ` Matt Armstrong
@ 2022-01-29 8:03 ` Saulius Menkevičius
2022-01-29 8:26 ` Eli Zaretskii
1 sibling, 0 replies; 39+ messages in thread
From: Saulius Menkevičius @ 2022-01-29 8:03 UTC (permalink / raw)
To: Matt Armstrong; +Cc: Eli Zaretskii, emacs-devel, p.stephani2, mituharu, alan
I did not register it yet. I was thinking about making a reduced test suite for this (small dotnet app+emacs code) to replicate the issue first.
And then I am waiting for a M1 MacBook to have shipped to me to test if the commit to switch to posix_spawn broke just Linux or macOS too. I have reports of x64/Linux breakage only at this point.
—Saulius Menkevičius
> Am 2022-01-28 um 19:12 schrieb Matt Armstrong <matt@rfc20.org>:
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> Date: Tue, 25 Jan 2022 14:25:23 +0200
>>> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
>>> Cc: p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
>>> emacs-devel@gnu.org
>>>
>>> I certainly cannot answer that, it probably does some kind of sniffing
>>> on FDs and changes behaviour.
>>>
>>> To actually figure that out I would need to build a minimal test fixture
>>> for this bug/issue and submit to dotnet/runtime repo on github for them
>>> to check and/or fix it.
>>
>> I think there's no way around this. We need at least to understand
>> what part of posix_spawn code interferes with pipe-based I/O used by
>> these LSP servers, and why.
>
> I don't find an emacs bug filed for this issue. Saulius, it would be
> good to file one.
>
> This issue tickled a memory I had of Python moving away from posix_spawn
> due to various portability issues: https://bugs.python.org/issue35823.
> The issues they ran into and solved may inform this investigation.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-28 17:12 ` Matt Armstrong
2022-01-29 8:03 ` Saulius Menkevičius
@ 2022-01-29 8:26 ` Eli Zaretskii
2022-01-31 20:48 ` Saulius Menkevicius
1 sibling, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-01-29 8:26 UTC (permalink / raw)
To: Matt Armstrong
Cc: sauliusmenkevicius, p.stephani2, alan, mituharu, emacs-devel
> From: Matt Armstrong <matt@rfc20.org>
> Cc: p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
> emacs-devel@gnu.org
> Date: Fri, 28 Jan 2022 09:12:22 -0800
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> To actually figure that out I would need to build a minimal test fixture
> >> for this bug/issue and submit to dotnet/runtime repo on github for them
> >> to check and/or fix it.
> >
> > I think there's no way around this. We need at least to understand
> > what part of posix_spawn code interferes with pipe-based I/O used by
> > these LSP servers, and why.
>
> I don't find an emacs bug filed for this issue. Saulius, it would be
> good to file one.
>
> This issue tickled a memory I had of Python moving away from posix_spawn
> due to various portability issues: https://bugs.python.org/issue35823.
> The issues they ran into and solved may inform this investigation.
Thanks.
I see nothing there about C#, nor even about problems with stdio
redirection in subprocesses. There's some reference to closing file
descriptors above 2, but AFAIU the problems in this bug report are
related to descriptors that aren't above 2.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-29 8:26 ` Eli Zaretskii
@ 2022-01-31 20:48 ` Saulius Menkevicius
2022-02-01 9:59 ` Robert Pluim
0 siblings, 1 reply; 39+ messages in thread
From: Saulius Menkevicius @ 2022-01-31 20:48 UTC (permalink / raw)
To: Eli Zaretskii, Matt Armstrong; +Cc: p.stephani2, alan, mituharu, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 3155 bytes --]
I did a bit more investigation (and still don't have a reproduction
vehicle) but it seems the problem has to do with signals (SIGCHLD in
particular) rather than stdio redirection.
Stack trace in the child process shows it has launched a subprocess
which has since exited but the child did not receive (?) SIGCHLD and
appears to be blocked.
Dotnet stack trace is
|[bob@fedora emacs]$ dotnet stack report -p 53193 Thread (0xCFC9):
[Native Frames]
System.Private.CoreLib!System.Threading.WaitHandle.WaitOneNoCheck(int32)
System.Private.CoreLib!System.Threading.WaitHandle.WaitOne(int32)
System.Diagnostics.Process!System.Diagnostics.ProcessWaitState.WaitForExit(int32)
System.Diagnostics.Process!System.Diagnostics.Process.WaitForExitCore(int32)
Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetDotNetBasePaths>d__5.MoveNext()
Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetInstances>d__4.MoveNext()
Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator+<GetInstances>d__20.MoveNext()
System.Linq!System.Linq.Enumerable.TryGetFirst(class
System.Collections.Generic.IEnumerable`1<!!0>,bool&)
System.Linq!System.Linq.Enumerable.FirstOrDefault(class
System.Collections.Generic.IEnumerable`1<!!0>)
Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults()
CSharpLanguageServer!CSharpLanguageServer.Program.entry(class
System.String[]) |
Where "ps axl" shows there is a zombie process waiting to be collected
but is not.
|0 1000 53193 53129 20 0 3437284 59416 - Ssl ? 0:00
/home/bob/src/csharp-language-server/src/CSharpLanguageServer/bin/Debug/net6.0/CSharpLanguageServer
0 1000 53203 53193 20 0 0 0 - Z ? 0:00 [dotnet] <defunct> |
Related emacs src/callproc.cs has code that has this comment:
/* Stop blocking SIGCHLD in the child. */
But I really don't know what should I do to attempt to fix this/find the
cause.
-Saulius
Am 29.01.22 um 10:26 schrieb Eli Zaretskii:
>> From: Matt Armstrong<matt@rfc20.org>
>> Cc:p.stephani2@gmail.com,alan@idiocy.org,mituharu@math.s.chiba-u.ac.jp,
>> emacs-devel@gnu.org
>> Date: Fri, 28 Jan 2022 09:12:22 -0800
>>
>> Eli Zaretskii<eliz@gnu.org> writes:
>>
>>>> To actually figure that out I would need to build a minimal test fixture
>>>> for this bug/issue and submit to dotnet/runtime repo on github for them
>>>> to check and/or fix it.
>>> I think there's no way around this. We need at least to understand
>>> what part of posix_spawn code interferes with pipe-based I/O used by
>>> these LSP servers, and why.
>> I don't find an emacs bug filed for this issue. Saulius, it would be
>> good to file one.
>>
>> This issue tickled a memory I had of Python moving away from posix_spawn
>> due to various portability issues:https://bugs.python.org/issue35823.
>> The issues they ran into and solved may inform this investigation.
> Thanks.
>
> I see nothing there about C#, nor even about problems with stdio
> redirection in subprocesses. There's some reference to closing file
> descriptors above 2, but AFAIU the problems in this bug report are
> related to descriptors that aren't above 2.
[-- Attachment #2: Type: text/html, Size: 4596 bytes --]
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-01-31 20:48 ` Saulius Menkevicius
@ 2022-02-01 9:59 ` Robert Pluim
2022-02-01 18:30 ` Saulius Menkevicius
2022-03-04 8:38 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master 2c79a8f 2/2: Use posix_spawn if possible.) Jürgen Hötzel
0 siblings, 2 replies; 39+ messages in thread
From: Robert Pluim @ 2022-02-01 9:59 UTC (permalink / raw)
To: Saulius Menkevicius
Cc: alan, emacs-devel, p.stephani2, Matt Armstrong, Eli Zaretskii,
mituharu
>>>>> On Mon, 31 Jan 2022 22:48:33 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
Saulius> I did a bit more investigation (and still don't have a reproduction
Saulius> vehicle) but it seems the problem has to do with signals (SIGCHLD in
Saulius> particular) rather than stdio redirection.
Saulius> Stack trace in the child process shows it has launched a subprocess
Saulius> which has since exited but the child did not receive (?) SIGCHLD and
Saulius> appears to be blocked.
Saulius> Dotnet stack trace is
Saulius> |[bob@fedora emacs]$ dotnet stack report -p 53193 Thread (0xCFC9):
Saulius> [Native Frames]
Saulius> System.Private.CoreLib!System.Threading.WaitHandle.WaitOneNoCheck(int32)
Saulius> System.Private.CoreLib!System.Threading.WaitHandle.WaitOne(int32)
Saulius> System.Diagnostics.Process!System.Diagnostics.ProcessWaitState.WaitForExit(int32)
Saulius> System.Diagnostics.Process!System.Diagnostics.Process.WaitForExitCore(int32)
Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetDotNetBasePaths>d__5.MoveNext()
Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetInstances>d__4.MoveNext()
Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator+<GetInstances>d__20.MoveNext()
Saulius> System.Linq!System.Linq.Enumerable.TryGetFirst(class
Saulius> System.Collections.Generic.IEnumerable`1<!!0>,bool&)
Saulius> System.Linq!System.Linq.Enumerable.FirstOrDefault(class
Saulius> System.Collections.Generic.IEnumerable`1<!!0>)
Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults()
Saulius> CSharpLanguageServer!CSharpLanguageServer.Program.entry(class
Saulius> System.String[]) |
Saulius> Where "ps axl" shows there is a zombie process waiting to be collected
Saulius> but is not.
Saulius> |0 1000 53193 53129 20 0 3437284 59416 - Ssl ? 0:00
Saulius> /home/bob/src/csharp-language-server/src/CSharpLanguageServer/bin/Debug/net6.0/CSharpLanguageServer
Saulius> 0 1000 53203 53193 20 0 0 0 - Z ? 0:00 [dotnet] <defunct> |
Saulius> Related emacs src/callproc.cs has code that has this comment:
Saulius> /* Stop blocking SIGCHLD in the child. */
Saulius> But I really don't know what should I do to attempt to fix this/find
Saulius> the cause.
Despite the comment, that code doesnʼt actually unblock SIGCHLD, it
just sets the child mask to be the same as the parent, and SIGCHLD and
SIGINT are blocked in the parent at this point.
Try the following:
diff --git a/src/callproc.c b/src/callproc.c
index 4d3b0bb8e0..2b4e8977a3 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1378,6 +1378,12 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
/* Stop blocking SIGCHLD in the child. */
sigset_t oldset;
error = pthread_sigmask (SIG_SETMASK, NULL, &oldset);
+ if (error != 0)
+ goto out;
+ error = sigdelset (&oldset, SIGCHLD);
+ if (error != 0)
+ goto out;
+ error = sigdelset (&oldset, SIGINT);
if (error != 0)
goto out;
error = posix_spawnattr_setsigmask (attributes, &oldset);
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-01 9:59 ` Robert Pluim
@ 2022-02-01 18:30 ` Saulius Menkevicius
2022-02-01 19:23 ` Robert Pluim
2022-03-04 8:38 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master 2c79a8f 2/2: Use posix_spawn if possible.) Jürgen Hötzel
1 sibling, 1 reply; 39+ messages in thread
From: Saulius Menkevicius @ 2022-02-01 18:30 UTC (permalink / raw)
To: Robert Pluim
Cc: alan, emacs-devel, p.stephani2, Matt Armstrong, Eli Zaretskii,
mituharu
Thanks Robert!
I applied your patch and that has actually has fixed the issue. So I
suggest this patch be applied on master.
-Saulius
Am 01.02.22 um 11:59 schrieb Robert Pluim:
>>>>>> On Mon, 31 Jan 2022 22:48:33 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
> Saulius> I did a bit more investigation (and still don't have a reproduction
> Saulius> vehicle) but it seems the problem has to do with signals (SIGCHLD in
> Saulius> particular) rather than stdio redirection.
>
> Saulius> Stack trace in the child process shows it has launched a subprocess
> Saulius> which has since exited but the child did not receive (?) SIGCHLD and
> Saulius> appears to be blocked.
>
> Saulius> Dotnet stack trace is
>
> Saulius> |[bob@fedora emacs]$ dotnet stack report -p 53193 Thread (0xCFC9):
> Saulius> [Native Frames]
> Saulius> System.Private.CoreLib!System.Threading.WaitHandle.WaitOneNoCheck(int32)
> Saulius> System.Private.CoreLib!System.Threading.WaitHandle.WaitOne(int32)
> Saulius> System.Diagnostics.Process!System.Diagnostics.ProcessWaitState.WaitForExit(int32)
> Saulius> System.Diagnostics.Process!System.Diagnostics.Process.WaitForExitCore(int32)
> Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetDotNetBasePaths>d__5.MoveNext()
> Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.DotNetSdkLocationHelper+<GetInstances>d__4.MoveNext()
> Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator+<GetInstances>d__20.MoveNext()
> Saulius> System.Linq!System.Linq.Enumerable.TryGetFirst(class
> Saulius> System.Collections.Generic.IEnumerable`1<!!0>,bool&)
> Saulius> System.Linq!System.Linq.Enumerable.FirstOrDefault(class
> Saulius> System.Collections.Generic.IEnumerable`1<!!0>)
> Saulius> Microsoft.Build.Locator!Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults()
> Saulius> CSharpLanguageServer!CSharpLanguageServer.Program.entry(class
> Saulius> System.String[]) |
>
> Saulius> Where "ps axl" shows there is a zombie process waiting to be collected
> Saulius> but is not.
>
> Saulius> |0 1000 53193 53129 20 0 3437284 59416 - Ssl ? 0:00
> Saulius> /home/bob/src/csharp-language-server/src/CSharpLanguageServer/bin/Debug/net6.0/CSharpLanguageServer
> Saulius> 0 1000 53203 53193 20 0 0 0 - Z ? 0:00 [dotnet] <defunct> |
>
>
> Saulius> Related emacs src/callproc.cs has code that has this comment:
>
> Saulius> /* Stop blocking SIGCHLD in the child. */
>
> Saulius> But I really don't know what should I do to attempt to fix this/find
> Saulius> the cause.
>
> Despite the comment, that code doesnʼt actually unblock SIGCHLD, it
> just sets the child mask to be the same as the parent, and SIGCHLD and
> SIGINT are blocked in the parent at this point.
>
> Try the following:
>
> diff --git a/src/callproc.c b/src/callproc.c
> index 4d3b0bb8e0..2b4e8977a3 100644
> --- a/src/callproc.c
> +++ b/src/callproc.c
> @@ -1378,6 +1378,12 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
> /* Stop blocking SIGCHLD in the child. */
> sigset_t oldset;
> error = pthread_sigmask (SIG_SETMASK, NULL, &oldset);
> + if (error != 0)
> + goto out;
> + error = sigdelset (&oldset, SIGCHLD);
> + if (error != 0)
> + goto out;
> + error = sigdelset (&oldset, SIGINT);
> if (error != 0)
> goto out;
> error = posix_spawnattr_setsigmask (attributes, &oldset);
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-01 18:30 ` Saulius Menkevicius
@ 2022-02-01 19:23 ` Robert Pluim
2022-02-01 19:52 ` Eli Zaretskii
0 siblings, 1 reply; 39+ messages in thread
From: Robert Pluim @ 2022-02-01 19:23 UTC (permalink / raw)
To: Saulius Menkevicius
Cc: alan, emacs-devel, p.stephani2, Matt Armstrong, Eli Zaretskii,
mituharu
>>>>> On Tue, 1 Feb 2022 20:30:18 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
Saulius> Thanks Robert!
Saulius> I applied your patch and that has actually has fixed the issue. So I
Saulius> suggest this patch be applied on master.
I can do that, if Eli/Lars agree. What should we do for emacs-28?
Apply it there or switch back to fork/vfork?
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-01 19:23 ` Robert Pluim
@ 2022-02-01 19:52 ` Eli Zaretskii
2022-02-02 8:30 ` Robert Pluim
0 siblings, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-02-01 19:52 UTC (permalink / raw)
To: Robert Pluim
Cc: alan, emacs-devel, sauliusmenkevicius, p.stephani2, matt,
mituharu
> From: Robert Pluim <rpluim@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, Matt Armstrong <matt@rfc20.org>,
> p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
> emacs-devel@gnu.org
> Date: Tue, 01 Feb 2022 20:23:23 +0100
>
> >>>>> On Tue, 1 Feb 2022 20:30:18 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
>
> Saulius> Thanks Robert!
> Saulius> I applied your patch and that has actually has fixed the issue. So I
> Saulius> suggest this patch be applied on master.
>
> I can do that, if Eli/Lars agree.
Are there any downsides to the patch? If not, I see no reasons not to
install that.
> What should we do for emacs-28?
Nothing, because on emacs-28 we use posix_spawn only on macOS.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-01 19:52 ` Eli Zaretskii
@ 2022-02-02 8:30 ` Robert Pluim
2022-02-02 8:54 ` Saulius Menkevičius
0 siblings, 1 reply; 39+ messages in thread
From: Robert Pluim @ 2022-02-02 8:30 UTC (permalink / raw)
To: Eli Zaretskii
Cc: alan, emacs-devel, sauliusmenkevicius, p.stephani2, matt,
mituharu
>>>>> On Tue, 01 Feb 2022 21:52:18 +0200, Eli Zaretskii <eliz@gnu.org> said:
>> From: Robert Pluim <rpluim@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, Matt Armstrong <matt@rfc20.org>,
>> p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
>> emacs-devel@gnu.org
>> Date: Tue, 01 Feb 2022 20:23:23 +0100
>>
>> >>>>> On Tue, 1 Feb 2022 20:30:18 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
>>
Saulius> Thanks Robert!
Saulius> I applied your patch and that has actually has fixed the issue. So I
Saulius> suggest this patch be applied on master.
>>
>> I can do that, if Eli/Lars agree.
Eli> Are there any downsides to the patch? If not, I see no reasons not to
Eli> install that.
Not as far as I can tell, but I shall test on a few more platforms
before pushing.
>> What should we do for emacs-28?
Eli> Nothing, because on emacs-28 we use posix_spawn only on macOS.
Right, Iʼd missed that, master it is then. We could put it in 28.2, I
guess, but I hadn't noticed any issues with subprocesses on emacs-28
on macOS.
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-02 8:30 ` Robert Pluim
@ 2022-02-02 8:54 ` Saulius Menkevičius
2022-02-07 21:12 ` Saulius Menkevicius
0 siblings, 1 reply; 39+ messages in thread
From: Saulius Menkevičius @ 2022-02-02 8:54 UTC (permalink / raw)
To: Robert Pluim
Cc: alan, emacs-devel, p.stephani2, matt, Eli Zaretskii, mituharu
I’ve just received a new Mac (arm64/M1) for myself so I can test if 28 has it broken on macOS too.
—Saulius Menkevičius
> Am 2022-02-02 um 10:30 schrieb Robert Pluim <rpluim@gmail.com>:
>
>
>>
>>>>>> On Tue, 01 Feb 2022 21:52:18 +0200, Eli Zaretskii <eliz@gnu.org> said:
>
>>> From: Robert Pluim <rpluim@gmail.com>
>>> Cc: Eli Zaretskii <eliz@gnu.org>, Matt Armstrong <matt@rfc20.org>,
>>> p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
>>> emacs-devel@gnu.org
>>> Date: Tue, 01 Feb 2022 20:23:23 +0100
>>>
>>>>>>>> On Tue, 1 Feb 2022 20:30:18 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
>>>
> Saulius> Thanks Robert!
> Saulius> I applied your patch and that has actually has fixed the issue. So I
> Saulius> suggest this patch be applied on master.
>>>
>>> I can do that, if Eli/Lars agree.
>
> Eli> Are there any downsides to the patch? If not, I see no reasons not to
> Eli> install that.
>
> Not as far as I can tell, but I shall test on a few more platforms
> before pushing.
>
>>> What should we do for emacs-28?
>
> Eli> Nothing, because on emacs-28 we use posix_spawn only on macOS.
>
> Right, Iʼd missed that, master it is then. We could put it in 28.2, I
> guess, but I hadn't noticed any issues with subprocesses on emacs-28
> on macOS.
>
> Robert
> --
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-02 8:54 ` Saulius Menkevičius
@ 2022-02-07 21:12 ` Saulius Menkevicius
2022-02-08 8:27 ` Robert Pluim
2022-02-08 12:12 ` Eli Zaretskii
0 siblings, 2 replies; 39+ messages in thread
From: Saulius Menkevicius @ 2022-02-07 21:12 UTC (permalink / raw)
To: Robert Pluim
Cc: Alan Third, emacs-devel, p.stephani2, Matt Armstrong,
Eli Zaretskii, mituharu
Hello Robert, Eli,
I can confirm that this patch is needed for emacs-28 too, as currently emacs on macOS blocks SIGCHLD the same way as it does on Linux.
Applying Robert’s patch on emacs-28 fixes the issue on macOS.
Tested on macOS 12.2 / aarch64.
-Saulius
> Am 2022-02-02 um 10:54 schrieb Saulius Menkevičius <sauliusmenkevicius@fastmail.com>:
>
> I’ve just received a new Mac (arm64/M1) for myself so I can test if 28 has it broken on macOS too.
>
> —Saulius Menkevičius
>
>> Am 2022-02-02 um 10:30 schrieb Robert Pluim <rpluim@gmail.com>:
>>
>>
>>>
>>>>>>> On Tue, 01 Feb 2022 21:52:18 +0200, Eli Zaretskii <eliz@gnu.org> said:
>>
>>>> From: Robert Pluim <rpluim@gmail.com>
>>>> Cc: Eli Zaretskii <eliz@gnu.org>, Matt Armstrong <matt@rfc20.org>,
>>>> p.stephani2@gmail.com, alan@idiocy.org, mituharu@math.s.chiba-u.ac.jp,
>>>> emacs-devel@gnu.org
>>>> Date: Tue, 01 Feb 2022 20:23:23 +0100
>>>>
>>>>>>>>> On Tue, 1 Feb 2022 20:30:18 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
>>>>
>> Saulius> Thanks Robert!
>> Saulius> I applied your patch and that has actually has fixed the issue. So I
>> Saulius> suggest this patch be applied on master.
>>>>
>>>> I can do that, if Eli/Lars agree.
>>
>> Eli> Are there any downsides to the patch? If not, I see no reasons not to
>> Eli> install that.
>>
>> Not as far as I can tell, but I shall test on a few more platforms
>> before pushing.
>>
>>>> What should we do for emacs-28?
>>
>> Eli> Nothing, because on emacs-28 we use posix_spawn only on macOS.
>>
>> Right, Iʼd missed that, master it is then. We could put it in 28.2, I
>> guess, but I hadn't noticed any issues with subprocesses on emacs-28
>> on macOS.
>>
>> Robert
>> --
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-07 21:12 ` Saulius Menkevicius
@ 2022-02-08 8:27 ` Robert Pluim
2022-02-08 12:12 ` Eli Zaretskii
1 sibling, 0 replies; 39+ messages in thread
From: Robert Pluim @ 2022-02-08 8:27 UTC (permalink / raw)
To: Saulius Menkevicius
Cc: Alan Third, emacs-devel, p.stephani2, Matt Armstrong,
Eli Zaretskii, mituharu
>>>>> On Mon, 7 Feb 2022 23:12:27 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
Saulius> Hello Robert, Eli,
Saulius> I can confirm that this patch is needed for emacs-28 too, as currently
Saulius> emacs on macOS blocks SIGCHLD the same way as it does on Linux.
Saulius> Applying Robert’s patch on emacs-28 fixes the issue on macOS.
Saulius> Tested on macOS 12.2 / aarch64.
OK. I haven't found any problems with it so far. Eli, where do you
want me to push it? (I could argue itʼs a regression, since emacs-27
used fork/vfork on macOS, and thus didnʼt have this issue).
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-07 21:12 ` Saulius Menkevicius
2022-02-08 8:27 ` Robert Pluim
@ 2022-02-08 12:12 ` Eli Zaretskii
2022-02-08 12:18 ` Saulius Menkevicius
1 sibling, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-02-08 12:12 UTC (permalink / raw)
To: Saulius Menkevicius
Cc: alan, rpluim, emacs-devel, p.stephani2, matt, mituharu
> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
> Date: Mon, 7 Feb 2022 23:12:27 +0200
> Cc: Alan Third <alan@idiocy.org>, emacs-devel@gnu.org, p.stephani2@gmail.com,
> Matt Armstrong <matt@rfc20.org>, Eli Zaretskii <eliz@gnu.org>,
> mituharu@math.s.chiba-u.ac.jp
>
> Hello Robert, Eli,
>
> I can confirm that this patch is needed for emacs-28 too, as currently emacs on macOS blocks SIGCHLD the same way as it does on Linux.
>
> Applying Robert’s patch on emacs-28 fixes the issue on macOS.
How important is this on macOS? I _really_ don't want to start
experiments with signals on the release branch, I prefer to tell users
C# is broken on macOS unless they either build without posix_spawn or
use the master branch.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-08 12:12 ` Eli Zaretskii
@ 2022-02-08 12:18 ` Saulius Menkevicius
2022-02-08 14:59 ` Robert Pluim
0 siblings, 1 reply; 39+ messages in thread
From: Saulius Menkevicius @ 2022-02-08 12:18 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: alan, rpluim, emacs-devel, p.stephani2, matt, mituharu
I believe this is not a problem related to C#/dotnet but generally with
how signals are blocked on child processes launched with posix_spawn in
the current implementation.
I will try to provide a minimal replication code that does not have
anything to do with dotnet/C#.
-Saulius
Am 08.02.22 um 14:12 schrieb Eli Zaretskii:
>> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
>> Date: Mon, 7 Feb 2022 23:12:27 +0200
>> Cc: Alan Third <alan@idiocy.org>, emacs-devel@gnu.org, p.stephani2@gmail.com,
>> Matt Armstrong <matt@rfc20.org>, Eli Zaretskii <eliz@gnu.org>,
>> mituharu@math.s.chiba-u.ac.jp
>>
>> Hello Robert, Eli,
>>
>> I can confirm that this patch is needed for emacs-28 too, as currently emacs on macOS blocks SIGCHLD the same way as it does on Linux.
>>
>> Applying Robert’s patch on emacs-28 fixes the issue on macOS.
> How important is this on macOS? I _really_ don't want to start
> experiments with signals on the release branch, I prefer to tell users
> C# is broken on macOS unless they either build without posix_spawn or
> use the master branch.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-08 12:18 ` Saulius Menkevicius
@ 2022-02-08 14:59 ` Robert Pluim
2022-02-08 21:09 ` Saulius Menkevicius
0 siblings, 1 reply; 39+ messages in thread
From: Robert Pluim @ 2022-02-08 14:59 UTC (permalink / raw)
To: Saulius Menkevicius
Cc: alan, emacs-devel, p.stephani2, matt, Eli Zaretskii, mituharu
>>>>> On Tue, 8 Feb 2022 14:18:43 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
Saulius> I believe this is not a problem related to C#/dotnet but generally
Saulius> with how signals are blocked on child processes launched with
Saulius> posix_spawn in the current implementation.
(I could argue that if dotnet wants to ensure it receives SIGCHLD, it
should unblock it itself, but thatʼs a different discussion, we
definitely have an Emacs bug)
And come to think of it, the posix_spawn code path is only exercised
when not asking for a pseudo tty. Since the default value for
`process-connection-type' is t => pty, Iʼm assuming that the elisp
code in question is binding that to nil, or using the :connection-type
argument to `make-process'.
Would it be possible to test using ptys? If that works thatʼs a
workaround that requires no changes to emacs-28.
Thanks
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-08 14:59 ` Robert Pluim
@ 2022-02-08 21:09 ` Saulius Menkevicius
2022-02-09 8:48 ` Robert Pluim
0 siblings, 1 reply; 39+ messages in thread
From: Saulius Menkevicius @ 2022-02-08 21:09 UTC (permalink / raw)
To: Robert Pluim
Cc: Alan Third, Emacs developers, p.stephani2, Matt Armstrong,
Eli Zaretskii, mituharu
[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]
Robert you are correct about ``:connection-type''. In particular lsp-mode specifies ``:connection-type pty'' here:
- https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6932 <https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6932>
As a workaround fsharp/csharp language servers can use shell wrapper for launching the server binaries, as "#!/bin/bash" will apparently normalize signal mask before launching sub-subprocess and things work alright from thereon.
This is not as nice as having things just working before this change to `make-process`, but at least we have some way to work around this issue..
-Saulius
> Am 2022-02-08 um 16:59 schrieb Robert Pluim <rpluim@gmail.com>:
>
>>>>>> On Tue, 8 Feb 2022 14:18:43 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
>
> Saulius> I believe this is not a problem related to C#/dotnet but generally
> Saulius> with how signals are blocked on child processes launched with
> Saulius> posix_spawn in the current implementation.
>
> (I could argue that if dotnet wants to ensure it receives SIGCHLD, it
> should unblock it itself, but thatʼs a different discussion, we
> definitely have an Emacs bug)
>
> And come to think of it, the posix_spawn code path is only exercised
> when not asking for a pseudo tty. Since the default value for
> `process-connection-type' is t => pty, Iʼm assuming that the elisp
> code in question is binding that to nil, or using the :connection-type
> argument to `make-process'.
>
> Would it be possible to test using ptys? If that works thatʼs a
> workaround that requires no changes to emacs-28.
>
> Thanks
>
> Robert
> --
[-- Attachment #2: Type: text/html, Size: 2885 bytes --]
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-08 21:09 ` Saulius Menkevicius
@ 2022-02-09 8:48 ` Robert Pluim
2022-02-12 8:44 ` Saulius Menkevicius
0 siblings, 1 reply; 39+ messages in thread
From: Robert Pluim @ 2022-02-09 8:48 UTC (permalink / raw)
To: Saulius Menkevicius
Cc: Alan Third, Emacs developers, p.stephani2, Matt Armstrong,
Eli Zaretskii, mituharu
>>>>> On Tue, 8 Feb 2022 23:09:20 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
Saulius> Robert you are correct about ``:connection-type''. In particular
Saulius> lsp-mode specifies ``:connection-type pty'' here:
':connection-type pipe', you mean. Does it still work if you use
'pty'?
Saulius> - https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6932
Saulius> <https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6932>
Saulius> As a workaround fsharp/csharp language servers can use shell wrapper
Saulius> for launching the server binaries, as "#!/bin/bash" will apparently
Saulius> normalize signal mask before launching sub-subprocess and things work
Saulius> alright from thereon.
Thatʼs to be expected. bash is a caring parent :-)
Saulius> This is not as nice as having things just working before this change
Saulius> to `make-process`, but at least we have some way to work around this
Saulius> issue..
OK. In that case Iʼll put it only in master.
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-09 8:48 ` Robert Pluim
@ 2022-02-12 8:44 ` Saulius Menkevicius
2022-02-12 8:59 ` Eli Zaretskii
0 siblings, 1 reply; 39+ messages in thread
From: Saulius Menkevicius @ 2022-02-12 8:44 UTC (permalink / raw)
To: Robert Pluim
Cc: Alan Third, Emacs developers, p.stephani2, Matt Armstrong,
Eli Zaretskii, mituharu
[-- Attachment #1: Type: text/plain, Size: 2227 bytes --]
Correct, I meant ":connection-type pipe“ when I referred to lsp-mode. My mistake. Curiously setting :connect-type to ’pty does not fix my issues on macOS+emacs-28 for me. I might be doing something wrong though.. Applying Robert’s patch does fix it on emacs-28 too.
And I was mistaken about /bin/bash reseting signal mask, ksh does it though.. https://unix.stackexchange.com/questions/123768/calling-sigprocmask-from-bash <https://unix.stackexchange.com/questions/123768/calling-sigprocmask-from-bash>.
So my workarounds to fix sigmask are as follows:
- on linux, I will wrap invocation of server process with „/usr/bin/env --default-signal“
- on macos, I will wrap invocation of server process with „/bin/ksh -c“
- .. not sure what is needed on *BSDs, probably the same thing as on macOS if they have /bin/ksh in default installation?
Are there any chances of getting this patch to fix signal mask to default after posix_spawn from Robert getting merged to master and/or emacs-28?
-Saulius
> Am 2022-02-09 um 10:48 schrieb Robert Pluim <rpluim@gmail.com>:
>
>>>>>> On Tue, 8 Feb 2022 23:09:20 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
>
> Saulius> Robert you are correct about ``:connection-type''. In particular
> Saulius> lsp-mode specifies ``:connection-type pty'' here:
>
> ':connection-type pipe', you mean. Does it still work if you use
> 'pty'?
>
> Saulius> - https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6932
> Saulius> <https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6932>
>
> Saulius> As a workaround fsharp/csharp language servers can use shell wrapper
> Saulius> for launching the server binaries, as "#!/bin/bash" will apparently
> Saulius> normalize signal mask before launching sub-subprocess and things work
> Saulius> alright from thereon.
>
> Thatʼs to be expected. bash is a caring parent :-)
>
> Saulius> This is not as nice as having things just working before this change
> Saulius> to `make-process`, but at least we have some way to work around this
> Saulius> issue..
>
> OK. In that case Iʼll put it only in master.
>
> Robert
> --
[-- Attachment #2: Type: text/html, Size: 3901 bytes --]
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-12 8:44 ` Saulius Menkevicius
@ 2022-02-12 8:59 ` Eli Zaretskii
2022-02-12 9:42 ` Saulius Menkevicius
0 siblings, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-02-12 8:59 UTC (permalink / raw)
To: Saulius Menkevicius
Cc: alan, rpluim, emacs-devel, p.stephani2, matt, mituharu
> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
> Date: Sat, 12 Feb 2022 10:44:21 +0200
> Cc: Eli Zaretskii <eliz@gnu.org>,
> Alan Third <alan@idiocy.org>,
> Emacs developers <emacs-devel@gnu.org>,
> p.stephani2@gmail.com,
> Matt Armstrong <matt@rfc20.org>,
> mituharu@math.s.chiba-u.ac.jp
>
> Are there any chances of getting this patch to fix signal mask to default after posix_spawn from Robert
> getting merged to master and/or emacs-28?
From my POV, it's too late to make such changes on the emacs-28
branch. We are too close to a release.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: master 2c79a8f 2/2: Use posix_spawn if possible.
2022-02-12 8:59 ` Eli Zaretskii
@ 2022-02-12 9:42 ` Saulius Menkevicius
0 siblings, 0 replies; 39+ messages in thread
From: Saulius Menkevicius @ 2022-02-12 9:42 UTC (permalink / raw)
To: Eli Zaretskii
Cc: Alan Third, Robert Pluim, Emacs developers, p.stephani2,
Matt Armstrong, mituharu
Very understandable.
OK, will proceed to apply workarounds in lsp-mode.
> Am 2022-02-12 um 10:59 schrieb Eli Zaretskii <eliz@gnu.org>:
>
>> From: Saulius Menkevicius <sauliusmenkevicius@fastmail.com>
>> Date: Sat, 12 Feb 2022 10:44:21 +0200
>> Cc: Eli Zaretskii <eliz@gnu.org>,
>> Alan Third <alan@idiocy.org>,
>> Emacs developers <emacs-devel@gnu.org>,
>> p.stephani2@gmail.com,
>> Matt Armstrong <matt@rfc20.org>,
>> mituharu@math.s.chiba-u.ac.jp
>>
>> Are there any chances of getting this patch to fix signal mask to default after posix_spawn from Robert
>> getting merged to master and/or emacs-28?
>
> From my POV, it's too late to make such changes on the emacs-28
> branch. We are too close to a release.
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master 2c79a8f 2/2: Use posix_spawn if possible.)
2022-02-01 9:59 ` Robert Pluim
2022-02-01 18:30 ` Saulius Menkevicius
@ 2022-03-04 8:38 ` Jürgen Hötzel
2022-03-04 10:07 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes Robert Pluim
1 sibling, 1 reply; 39+ messages in thread
From: Jürgen Hötzel @ 2022-03-04 8:38 UTC (permalink / raw)
To: Robert Pluim
Cc: alan, emacs-devel, Saulius Menkevicius, p.stephani2,
Matt Armstrong, Eli Zaretskii, mituharu
[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]
Robert Pluim <rpluim@gmail.com> writes:
>>>>>> On Mon, 31 Jan 2022 22:48:33 +0200, Saulius Menkevicius <sauliusmenkevicius@fastmail.com> said:
> Try the following:
>
> diff --git a/src/callproc.c b/src/callproc.c
> index 4d3b0bb8e0..2b4e8977a3 100644
> --- a/src/callproc.c
> +++ b/src/callproc.c
> @@ -1378,6 +1378,12 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
> /* Stop blocking SIGCHLD in the child. */
> sigset_t oldset;
^^^ This is the root-cause of the issue:
A new/invalid signal mask is introduced.
The correct oldset mask from emacs_spawn(...,const sigset_t *oldset) is
simply ignored.
> error = pthread_sigmask (SIG_SETMASK, NULL, &oldset);
> + if (error != 0)
> + goto out;
> + error = sigdelset (&oldset, SIGCHLD);
> + if (error != 0)
> + goto out;
> + error = sigdelset (&oldset, SIGINT);
> if (error != 0)
> goto out;
> error = posix_spawnattr_setsigmask (attributes, &oldset);
IMO the correct way to fix this issue is to use the oldset passed by
emacs_spawn (patch enclosed) just like the fork/exec implementation does.
I guess without a fix many forking commands (that don't examine and
change mask of blocked signals) will "hang" in Emacs.
"dotnet" is just a prominent one.
Jürgen
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Use correct signal oldset in posix_spawn implementation --]
[-- Type: text/x-patch, Size: 2748 bytes --]
From f691f4c304d226f99ac0377de3b6186154c0d8fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6tzel?= <juergen@archlinux.org>
Date: Fri, 4 Mar 2022 10:08:14 +0100
Subject: [PATCH] Use correct signal oldset in posix_spawn implementation
* src/callproc.c (emacs_spawn): Pass oldset parameter.
(emacs_posix_spawn_init_attributes): Use correct oldset.
(emacs_posix_spawn_init): remove intermediate function.
---
src/callproc.c | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/src/callproc.c b/src/callproc.c
index 018c9ce690..0922e10f01 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1335,7 +1335,8 @@ emacs_posix_spawn_init_actions (posix_spawn_file_actions_t *actions,
}
static int
-emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
+emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes,
+ const sigset_t *oldset)
{
int error = posix_spawnattr_init (attributes);
if (error != 0)
@@ -1377,11 +1378,7 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
goto out;
/* Stop blocking SIGCHLD in the child. */
- sigset_t oldset;
- error = pthread_sigmask (SIG_SETMASK, NULL, &oldset);
- if (error != 0)
- goto out;
- error = posix_spawnattr_setsigmask (attributes, &oldset);
+ error = posix_spawnattr_setsigmask (attributes, oldset);
if (error != 0)
goto out;
@@ -1392,23 +1389,6 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t *attributes)
return error;
}
-static int
-emacs_posix_spawn_init (posix_spawn_file_actions_t *actions,
- posix_spawnattr_t *attributes, int std_in,
- int std_out, int std_err, const char *cwd)
-{
- int error = emacs_posix_spawn_init_actions (actions, std_in,
- std_out, std_err, cwd);
- if (error != 0)
- return error;
-
- error = emacs_posix_spawn_init_attributes (attributes);
- if (error != 0)
- return error;
-
- return 0;
-}
-
#endif
/* Start a new asynchronous subprocess. If successful, return zero
@@ -1443,9 +1423,12 @@ emacs_spawn (pid_t *newpid, int std_in, int std_out, int std_err,
if (use_posix_spawn)
{
/* Initialize optional attributes before blocking. */
- int error
- = emacs_posix_spawn_init (&actions, &attributes, std_in,
- std_out, std_err, cwd);
+ int error = emacs_posix_spawn_init_actions (&actions, std_in,
+ std_out, std_err, cwd);
+ if (error != 0)
+ return error;
+
+ error = emacs_posix_spawn_init_attributes (&attributes, oldset);
if (error != 0)
return error;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-03-04 8:38 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master 2c79a8f 2/2: Use posix_spawn if possible.) Jürgen Hötzel
@ 2022-03-04 10:07 ` Robert Pluim
2022-03-04 15:41 ` Jürgen Hötzel
2022-04-04 14:13 ` Robert Pluim
0 siblings, 2 replies; 39+ messages in thread
From: Robert Pluim @ 2022-03-04 10:07 UTC (permalink / raw)
To: Jürgen Hötzel
Cc: alan, emacs-devel, Saulius Menkevicius, p.stephani2,
Matt Armstrong, Eli Zaretskii, mituharu
>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, Jürgen Hötzel <juergen@hoetzel.info> said:
Jürgen> IMO the correct way to fix this issue is to use the oldset passed by
Jürgen> emacs_spawn (patch enclosed) just like the fork/exec implementation does.
Sure, that would work as well.
Jürgen> I guess without a fix many forking commands (that don't examine and
Jürgen> change mask of blocked signals) will "hang" in Emacs.
Not really. Itʼs a code path thatʼs non-default, since
process-connection-type defaults to t => use pty's, and the command in
question has to care about its children. But it needs to be fixed
regardless.
I donʼt have a test case, but the patch looks good to me.
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-03-04 10:07 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes Robert Pluim
@ 2022-03-04 15:41 ` Jürgen Hötzel
2022-03-04 16:08 ` Robert Pluim
2022-04-17 18:22 ` Philipp Stephani
2022-04-04 14:13 ` Robert Pluim
1 sibling, 2 replies; 39+ messages in thread
From: Jürgen Hötzel @ 2022-03-04 15:41 UTC (permalink / raw)
To: Robert Pluim
Cc: alan, emacs-devel, Saulius Menkevicius, p.stephani2,
Matt Armstrong, Eli Zaretskii, mituharu
Robert Pluim <rpluim@gmail.com> writes:
>>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, Jürgen Hötzel <juergen@hoetzel.info> said:
> Jürgen> IMO the correct way to fix this issue is to use the oldset passed by
> Jürgen> emacs_spawn (patch enclosed) just like the fork/exec implementation does.
>
> Sure, that would work as well.
>
> Jürgen> I guess without a fix many forking commands (that don't examine and
> Jürgen> change mask of blocked signals) will "hang" in Emacs.
>
> Not really. Itʼs a code path thatʼs non-default, since
> process-connection-type defaults to t => use pty's, and the command in
‘call-process’ invokes emacs_spawn 'call-process' with pty set to NULL
so ‘process-connection-type’ doesn't have an effect here.
A minimal C example to reproduce the HANG is
--8<---------------cut here---------------start hang.c------------->8---
#include <signal.h>
#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
void chld_handler(int signum) { printf("\nInside CHLD handler function\n"); }
int main(int argc, char *argv[]) {
sigset_t blocked, old;
signal(SIGCHLD, chld_handler); // Setup Child handler
sigemptyset(&blocked);
sigaddset(&blocked, SIGCHLD);
sigprocmask(SIG_BLOCK, &blocked, &old);
if (!fork()) {
return 0; /* child signals SIGCHLD */
}
sigsuspend(&old); /* WAITS for ever when SIGCHILD was originally blocked */
printf("Parent terminates\n");
return 0;
}
--8<---------------cut here---------------end hang.c--------------->8---
(call-process "chldtest" nil t nil) will never return.
Regards, Jürgen
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-03-04 15:41 ` Jürgen Hötzel
@ 2022-03-04 16:08 ` Robert Pluim
2022-04-17 18:22 ` Philipp Stephani
1 sibling, 0 replies; 39+ messages in thread
From: Robert Pluim @ 2022-03-04 16:08 UTC (permalink / raw)
To: Jürgen Hötzel
Cc: alan, emacs-devel, Saulius Menkevicius, p.stephani2,
Matt Armstrong, Eli Zaretskii, mituharu
>>>>> On Fri, 04 Mar 2022 16:41:15 +0100, Jürgen Hötzel <juergen@hoetzel.info> said:
Jürgen> Robert Pluim <rpluim@gmail.com> writes:
>>>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, Jürgen Hötzel <juergen@hoetzel.info> said:
Jürgen> IMO the correct way to fix this issue is to use the oldset passed by
Jürgen> emacs_spawn (patch enclosed) just like the fork/exec implementation does.
>>
>> Sure, that would work as well.
>>
Jürgen> I guess without a fix many forking commands (that don't examine and
Jürgen> change mask of blocked signals) will "hang" in Emacs.
>>
>> Not really. Itʼs a code path thatʼs non-default, since
>> process-connection-type defaults to t => use pty's, and the command in
Jürgen> ‘call-process’ invokes emacs_spawn 'call-process' with pty set to NULL
Jürgen> so ‘process-connection-type’ doesn't have an effect here.
Yes. And this change to use emacs_spawn has been in master for a
while, and we've had exactly one complaint, which leads me to suspect
that either people donʼt `call-process' processes that are affected by
the incorrect SIGCHLD handling, or that `make-process' is mostly used
with the default setting of `process-connection-type'.
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-03-04 10:07 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes Robert Pluim
2022-03-04 15:41 ` Jürgen Hötzel
@ 2022-04-04 14:13 ` Robert Pluim
1 sibling, 0 replies; 39+ messages in thread
From: Robert Pluim @ 2022-04-04 14:13 UTC (permalink / raw)
To: Jürgen Hötzel
Cc: alan, emacs-devel, Saulius Menkevicius, p.stephani2,
Matt Armstrong, Eli Zaretskii, mituharu
>>>>> On Fri, 04 Mar 2022 11:07:52 +0100, Robert Pluim <rpluim@gmail.com> said:
>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, Jürgen Hötzel <juergen@hoetzel.info> said:
Jürgen> IMO the correct way to fix this issue is to use the oldset passed by
Jürgen> emacs_spawn (patch enclosed) just like the fork/exec implementation does.
Robert> Sure, that would work as well.
Jürgen> I guess without a fix many forking commands (that don't examine and
Jürgen> change mask of blocked signals) will "hang" in Emacs.
Robert> Not really. Itʼs a code path thatʼs non-default, since
Robert> process-connection-type defaults to t => use pty's, and the command in
Robert> question has to care about its children. But it needs to be fixed
Robert> regardless.
Robert> I donʼt have a test case, but the patch looks good to me.
Now applied to master as 8103b060d8 in Jürgen's name.
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-03-04 15:41 ` Jürgen Hötzel
2022-03-04 16:08 ` Robert Pluim
@ 2022-04-17 18:22 ` Philipp Stephani
2022-04-19 14:36 ` Robert Pluim
1 sibling, 1 reply; 39+ messages in thread
From: Philipp Stephani @ 2022-04-17 18:22 UTC (permalink / raw)
To: Jürgen Hötzel
Cc: Alan Third, Robert Pluim, emacs-devel, Saulius Menkevicius,
Matt Armstrong, Eli Zaretskii, YAMAMOTO Mitsuharu
> Am 04.03.2022 um 16:41 schrieb Jürgen Hötzel <juergen@hoetzel.info>:
>
>
> Robert Pluim <rpluim@gmail.com> writes:
>
>>>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, Jürgen Hötzel <juergen@hoetzel.info> said:
>> Jürgen> IMO the correct way to fix this issue is to use the oldset passed by
>> Jürgen> emacs_spawn (patch enclosed) just like the fork/exec implementation does.
>>
>> Sure, that would work as well.
>>
>> Jürgen> I guess without a fix many forking commands (that don't examine and
>> Jürgen> change mask of blocked signals) will "hang" in Emacs.
>>
>> Not really. Itʼs a code path thatʼs non-default, since
>> process-connection-type defaults to t => use pty's, and the command in
>
> ‘call-process’ invokes emacs_spawn 'call-process' with pty set to NULL
> so ‘process-connection-type’ doesn't have an effect here.
>
> A minimal C example to reproduce the HANG is
>
> --8<---------------cut here---------------start hang.c------------->8---
> #include <signal.h>
> #include <stdio.h>
> #include <sys/wait.h>
> #include <unistd.h>
>
> void chld_handler(int signum) { printf("\nInside CHLD handler function\n"); }
>
> int main(int argc, char *argv[]) {
> sigset_t blocked, old;
>
> signal(SIGCHLD, chld_handler); // Setup Child handler
> sigemptyset(&blocked);
> sigaddset(&blocked, SIGCHLD);
> sigprocmask(SIG_BLOCK, &blocked, &old);
> if (!fork()) {
> return 0; /* child signals SIGCHLD */
> }
> sigsuspend(&old); /* WAITS for ever when SIGCHILD was originally blocked */
> printf("Parent terminates\n");
> return 0;
> }
> --8<---------------cut here---------------end hang.c--------------->8---
>
>
> (call-process "chldtest" nil t nil) will never return.
If not already done, would you mind installing this example as a new regression test? This area seems subtle enough that we'd benefit from testing the behavior explicitly.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-04-17 18:22 ` Philipp Stephani
@ 2022-04-19 14:36 ` Robert Pluim
2022-04-19 14:48 ` Philipp Stephani
2022-04-19 16:07 ` Eli Zaretskii
0 siblings, 2 replies; 39+ messages in thread
From: Robert Pluim @ 2022-04-19 14:36 UTC (permalink / raw)
To: Philipp Stephani
Cc: Alan Third, Jürgen Hötzel, emacs-devel,
Saulius Menkevicius, Matt Armstrong, Eli Zaretskii,
YAMAMOTO Mitsuharu
>>>>> On Sun, 17 Apr 2022 20:22:13 +0200, Philipp Stephani <p.stephani2@gmail.com> said:
Philipp> If not already done, would you mind installing this example as a new
Philipp> regression test? This area seems subtle enough that we'd benefit from
Philipp> testing the behavior explicitly.
I donʼt think our test suite has support for compiling C programs
(Emacs C modules yes, but not standalone programs).
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-04-19 14:36 ` Robert Pluim
@ 2022-04-19 14:48 ` Philipp Stephani
2022-04-19 16:07 ` Eli Zaretskii
1 sibling, 0 replies; 39+ messages in thread
From: Philipp Stephani @ 2022-04-19 14:48 UTC (permalink / raw)
To: Robert Pluim
Cc: Alan Third, Jürgen Hötzel, Emacs developers,
Saulius Menkevicius, Matt Armstrong, Eli Zaretskii,
YAMAMOTO Mitsuharu
> Am 19.04.2022 um 16:36 schrieb Robert Pluim <rpluim@gmail.com>:
>
>>>>>> On Sun, 17 Apr 2022 20:22:13 +0200, Philipp Stephani <p.stephani2@gmail.com> said:
>
> Philipp> If not already done, would you mind installing this example as a new
> Philipp> regression test? This area seems subtle enough that we'd benefit from
> Philipp> testing the behavior explicitly.
>
> I donʼt think our test suite has support for compiling C programs
> (Emacs C modules yes, but not standalone programs).
I wouldn't expect that we'd need specific support for that, it's just another Make target.
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-04-19 14:36 ` Robert Pluim
2022-04-19 14:48 ` Philipp Stephani
@ 2022-04-19 16:07 ` Eli Zaretskii
2022-04-19 17:32 ` Robert Pluim
1 sibling, 1 reply; 39+ messages in thread
From: Eli Zaretskii @ 2022-04-19 16:07 UTC (permalink / raw)
To: Robert Pluim
Cc: alan, juergen, emacs-devel, sauliusmenkevicius, p.stephani2, matt,
mituharu
> From: Robert Pluim <rpluim@gmail.com>
> Gmane-Reply-To-List: yes
> Date: Tue, 19 Apr 2022 16:36:03 +0200
> Cc: Alan Third <alan@idiocy.org>,
> Jürgen Hötzel <juergen@hoetzel.info>,
> emacs-devel@gnu.org, Saulius Menkevicius <sauliusmenkevicius@fastmail.com>,
> Matt Armstrong <matt@rfc20.org>, Eli Zaretskii <eliz@gnu.org>,
> YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
>
> >>>>> On Sun, 17 Apr 2022 20:22:13 +0200, Philipp Stephani <p.stephani2@gmail.com> said:
>
> Philipp> If not already done, would you mind installing this example as a new
> Philipp> regression test? This area seems subtle enough that we'd benefit from
> Philipp> testing the behavior explicitly.
>
> I donʼt think our test suite has support for compiling C programs
> (Emacs C modules yes, but not standalone programs).
You could perhaps use Emacs as such a "C program"?
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
2022-04-19 16:07 ` Eli Zaretskii
@ 2022-04-19 17:32 ` Robert Pluim
0 siblings, 0 replies; 39+ messages in thread
From: Robert Pluim @ 2022-04-19 17:32 UTC (permalink / raw)
To: Eli Zaretskii
Cc: alan, juergen, emacs-devel, sauliusmenkevicius, p.stephani2, matt,
mituharu
>>>>> On Tue, 19 Apr 2022 19:07:35 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> I donʼt think our test suite has support for compiling C programs
>> (Emacs C modules yes, but not standalone programs).
Eli> You could perhaps use Emacs as such a "C program"?
Yes, except that running emacs from emacs doesnʼt fail the way the
example program does 🙂
Robert
--
^ permalink raw reply [flat|nested] 39+ messages in thread
end of thread, other threads:[~2022-04-19 17:32 UTC | newest]
Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-25 6:48 master 2c79a8f 2/2: Use posix_spawn if possible Saulius Menkevicius
2022-01-25 8:41 ` Eli Zaretskii
2022-01-25 8:58 ` Saulius Menkevicius
2022-01-25 11:46 ` Jostein Kjønigsen
2022-01-25 11:55 ` Po Lu
2022-01-25 12:22 ` Eli Zaretskii
2022-01-25 12:25 ` Saulius Menkevicius
2022-01-25 13:47 ` Eli Zaretskii
2022-01-28 17:12 ` Matt Armstrong
2022-01-29 8:03 ` Saulius Menkevičius
2022-01-29 8:26 ` Eli Zaretskii
2022-01-31 20:48 ` Saulius Menkevicius
2022-02-01 9:59 ` Robert Pluim
2022-02-01 18:30 ` Saulius Menkevicius
2022-02-01 19:23 ` Robert Pluim
2022-02-01 19:52 ` Eli Zaretskii
2022-02-02 8:30 ` Robert Pluim
2022-02-02 8:54 ` Saulius Menkevičius
2022-02-07 21:12 ` Saulius Menkevicius
2022-02-08 8:27 ` Robert Pluim
2022-02-08 12:12 ` Eli Zaretskii
2022-02-08 12:18 ` Saulius Menkevicius
2022-02-08 14:59 ` Robert Pluim
2022-02-08 21:09 ` Saulius Menkevicius
2022-02-09 8:48 ` Robert Pluim
2022-02-12 8:44 ` Saulius Menkevicius
2022-02-12 8:59 ` Eli Zaretskii
2022-02-12 9:42 ` Saulius Menkevicius
2022-03-04 8:38 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master 2c79a8f 2/2: Use posix_spawn if possible.) Jürgen Hötzel
2022-03-04 10:07 ` [PATCH] posix_spawn blocks SIGCHLD in spawned processes Robert Pluim
2022-03-04 15:41 ` Jürgen Hötzel
2022-03-04 16:08 ` Robert Pluim
2022-04-17 18:22 ` Philipp Stephani
2022-04-19 14:36 ` Robert Pluim
2022-04-19 14:48 ` Philipp Stephani
2022-04-19 16:07 ` Eli Zaretskii
2022-04-19 17:32 ` Robert Pluim
2022-04-04 14:13 ` Robert Pluim
2022-01-25 13:15 ` master 2c79a8f 2/2: Use posix_spawn if possible Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.