-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing EINTR handling on macOS for opendir/readdir/closedir syscalls #20799
Comments
For mono/mono, due to thread aborts and interrupts, this has ot be handled in a similar way to #7255 We can't just look in native checking for There's a related change to the pal code too Basically the issue is the way mono aborts threads. A thread abort interrupts the thread, breaking syscalls, and sets some state that the thread will examine when it returns to managed. If the thread never returns to managed and just loops in native code, it will never abort. (See |
@lambdageek dotnet/runtime PR has been merged. |
For Mono we must loop in managed when opendir/readdir/closedir return EINTR in order to handle Thread.Abort. This is because while a thread abort will break syscalls with EINTR, throwing the ThreadAbortException will only happen when the pinvoke returns. (Although opendir/readdir/clsoedir are not documented to return EINTR, they do so on macOS Big Sur under certain conditions, so we will need to add managed looping) Related to mono/mono#20799
For Mono we must loop in managed when opendir/readdir/closedir return EINTR in order to handle Thread.Abort. This is because while a thread abort will break syscalls with EINTR, throwing the ThreadAbortException will only happen when the pinvoke returns. (Although opendir/readdir/clsoedir are not documented to return EINTR, they do so on macOS Big Sur under certain conditions, so we will need to add managed looping) Related to mono/mono#20799
Handle EINTR for opendir/readdir/closedir. Because of how thread aborts work, we must loop in managed. A thread abort will break syscalls and return EINTR, but mono will not raise a ThreadAbortException until a pinvoke returns. (Despite the documentation, opendir/readdir/closedir sometimes return EINTR on macOS Big Sur.) Related to mono#20799
Handle EINTR for opendir/readdir/closedir. Because of how thread aborts work, we must loop in managed. A thread abort will break syscalls and return EINTR, but mono will not raise a ThreadAbortException until a pinvoke returns. (Despite the documentation, opendir/readdir/closedir sometimes return EINTR on macOS Big Sur.) Related to mono#20799
* [System.Native] Handle ReadDir EINTR Handle EINTR for opendir/readdir/closedir. Because of how thread aborts work, we must loop in managed. A thread abort will break syscalls and return EINTR, but mono will not raise a ThreadAbortException until a pinvoke returns. (Despite the documentation, opendir/readdir/closedir sometimes return EINTR on macOS Big Sur.) Related to #20799 * bump corefx * [System] on unix, include Interop.ReadDir.Mono.cs on mac it's in corlib, on unix and android it's in System, for some reason * Add newline Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
* [System.Native] Handle ReadDir EINTR Handle EINTR for opendir/readdir/closedir. Because of how thread aborts work, we must loop in managed. A thread abort will break syscalls and return EINTR, but mono will not raise a ThreadAbortException until a pinvoke returns. (Despite the documentation, opendir/readdir/closedir sometimes return EINTR on macOS Big Sur.) Related to #20799 * bump corefx * [System] on unix, include Interop.ReadDir.Mono.cs on mac it's in corlib, on unix and android it's in System, for some reason * Add newline Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Fixed on mono main and 2020-02 |
(Thanks to @Therzok for filing a related issue to dotnet/runtime: dotnet/runtime#47584 )
Note the issue is different in mono/mono due to Thread.Abort and Thread.Interrupt
Description
It seems that under certain conditions, the
opendir
,readdir
,closedir
can seterrno
toEINTR
.The 3 syscalls are the only ones in pal_io.c that are not handling EINTR in native, but they also don't handle it in managed.
https://github.com/mono/corefx/blob/7c24bb0756fd39fbf09b8777f25c15d21d78eb46/src/Native/Unix/System.Native/pal_io.c#L468
Note: it is not documented in the man pages, but it seems to be a problem in practice.
Configuration
Mono 2020-02, macOS, x64. Not specific to this.
Regression?
Only started happening with macOS Big Sur.
Other information
See this gist for an exception being bubbled on mono which is using the same source as dotnet/runtime.
The text was updated successfully, but these errors were encountered: