ArgumentOutOfRangeException in NtProcessInfoHelper.GetProcessInfos when retrieving Process.SessionId #108798
Labels
area-System.Diagnostics.Process
needs-author-action
An issue or pull request that requires more info or actions from the author.
Milestone
Description
Hi team 👋 , I'm running into the following
ArgumentOutOfRangeException
on all of the machines of a certain customer, when making a simple call to retrieve the current process'SessionId
. For context, we're talking about a .NET 8.0.0 (sdk: 8.0.100) WPF application.The exception occurs when trying to
Slice
theReadOnlySpan
.This is the code triggering the exception:
We cannot debug on the customer's machine, but we were able to capture a memory dump of the process when it crashed. Based on that dump, I've managed to extract the
byte[]
returned byNtQuerySystemInformation
and what happens is:881112
NextEntryOffset
toprocessInformationOffset
we reach an offset of881296
at some point, which is outside the bufferSplice
throws anArgumentOutOfRangeException
I've turned the dotnet code upside down and on all sides, and I cannot figure out a code path on which this could possibly happen.
Interop.NtDll.NtQuerySystemInformation
looks to provide a snapshot in time of the processes, so there should be no overrun due to newly created processes. The only other option is thatInterop.NtDll.NtQuerySystemInformation
returns invalid data._Some other things we've tried:
Thoughts on why this might happen / how we could troubleshoot this further? Any help would be greatly appreciated, thank you!
Reproduction Steps
Expected behavior
No exception is thrown and the correct
SessionId
is returned.Actual behavior
ArgumentOutOfRangeException
is thrown when retrieving theSessionId
.Regression?
On the same machines, a .NET 6 version of the same application works without any issues. Though this might no be very relevant, since we're not able to reproduce this with a .NET 8 console application either.
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: