-
Notifications
You must be signed in to change notification settings - Fork 4.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
AccessViolationException when calling Process.HandleCount #107503
Comments
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
Though I suppose its more |
Getting a similar errors in linux net9, some stack traces below, file enumeration seems unstable:
|
This looks like some subtle bug in the unsafe code in @Martin-Molinero Any chance you can share a crash dump for this failure? The best way to share crash dump with us is to open an issue on https://developercommunity.visualstudio.com/ and attach the crash dump to it as a private attachment. Unlike github issues, https://developercommunity.visualstudio.com/ does not have problematic limits on the size of attachments and the attachments are not publicly visible. |
Given how commonly used the helper is ( The only use of runtime/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs Lines 29 to 32 in ff604c2
runtime/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs Lines 42 to 45 in ff604c2
I bet this should be using Looks like we were using
runtime/src/native/libs/System.Native/pal_io.c Lines 494 to 498 in ff604c2
|
Tagging subscribers to this area: @dotnet/area-system-io |
Hey! Sorry tried quite a few times to reproduce today enabling the dump generation and guess what, can't reproduce, if I see it again I'll share a dump asap 💯 just some extra details: seen it happen enumerating ~100k files order of magnitude, big host (ram/cores), lots of action happening => sounds like an extreme race condition |
How would that happen? Linux has runtime/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs Lines 48 to 49 in c9af66c
|
Reading unaligned vector beyond page size? Had this issue previously when using IndexOf for searching for null terminators of strings (Terminator within page, but vector read spills over) |
Yep, that's what my guess was, which is resolvable by using |
Description
Calling
Process.HandleCount
on a cached handle can cause anAccessViolationException
on Linux (WSL)Reproduction Steps
https://github.com/prometheus-net/prometheus-net/blob/60e9106a83ff1274fec0022c37366f04822b1d1b/Prometheus/DotNetStats.cs#L74-L97
Expected behavior
Calling
UpdateMetrics
sets the number of process handlesActual behavior
Infrequent (about 6 hours of being called every 5 seconds)
Regression?
Not sure as first time have run on WSL; haven't had any issues on Windows or seen any complaints from Linux, macOS users
Known Workarounds
No workaround as
AccessViolationException
always bubbles through catches to crash processConfiguration
WSL on Windows 11 23H2 (OS Build 22631.4112)
Other information
Aside; creating all the strings for the filenames in
/proc/{pid}/fd
just to find the count of files doesn't seem very efficientruntime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Linux.cs
Line 172 in c4792a2
The text was updated successfully, but these errors were encountered: