-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
Description
Related to #120577.
The assert at
runtime/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs
Line 340 in cbf483b
Debug.Assert(Interop.Sys.LSeek(this, 0, Interop.Sys.SeekWhence.SEEK_CUR) >= 0); |
trips on AzureLinux 3 when opening pseudofiles such as /proc/net/route
. The assert has been relaxed by #120736 to unblock CI (as the tests don't fail on Release builds since they don't actually seek in the file), but following piece of code still throws on AzureLinux3
FileStream file = new FileStream("/proc/net/route", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
// Position: 0, CanSeek: True, Length: 0
System.Console.WriteLine($"Position: {file.Position}, CanSeek: {file.CanSeek}, Length: {file.Length}");
file.Position = 1; // this updates internal offset, but does not actually call lseek()
// accessing the file handle attempts to synchronize the offset by lseek() and throws
// System.IO.IOException : Illegal seek : '/proc/net/route'
System.Console.WriteLine($"SafeFileHandle: {file.SafeFileHandle}");
I don't have access to an AzureLinux VM to do more experiments (this does not reproduce via docker), but we should also check if Seek() followed by Read actually reads data at given offset from the pseudofile.
Copilot