-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Improve Interop.Sys.ReadLink loop with stackalloc #69335
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io |
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
|
/cc @dotnet/interop-contrib |
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
|
I'm not clear on why this change is so involved. If the goal here is just to use an initial stackalloc, why isn't it something more like main...stephentoub:runtime:readlinkstackalloc ? |
see this discussion : Rent may override last return (external code is depending on ReadLink last return to validate for example whether the file is really a symbolic link). So we need to relocate all validations done outside ReadLink scope and do it inside. We should also take into account that some callers do not care about validation, they want just the result. |
Isn't that a separate issue from the stackalloc, and one that already exists? Addressing that also shouldn't require lots of additional changes: the original error code can just be stored into a local with Marshal.GetLastPInvokeError and then restored as the very last thing done with Marshal.SetLastPInvokeError. |
Some of the callers ignore all errors (including the unexpected errors) and assumed that (It is fine to not address this issue as part of this PR.) |
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
it is correct |
Thanks. Then yeah, sounds like those call sites should be fixed separately after this PR goes in. |
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadLink.cs
Outdated
Show resolved
Hide resolved
| internal static string? ReadLink(ReadOnlySpan<char> path) | ||
| { | ||
| int outputBufferSize = 1024; | ||
| const int stackBufferSize = 256; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: StackBufferSize
stephentoub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Opened #71970 |
Fixes #69230