-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Relax LinkTarget so it always returns null when steps on an error #55668
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsMotivated by #55664. When I was testing that PR, I noticed that I was getting ACCESS DENIED errors sporadically, here's the callstack:
I suspect is because of the following (even though I am getting the error when calling runtime/src/libraries/Common/src/System/IO/FileSystem.Attributes.Windows.cs Lines 73 to 76 in 44f7103
I wasn't able to create a unit case that consistently could hit this issue but by always returning This also grants us parity with the Unix implementation.
|
@@ -600,13 +604,15 @@ uint GetFinalPathNameByHandle(SafeFileHandle handle, char[] buffer) | |||
{ | |||
// Since all these paths will be passed to CreateFile, which takes a string anyway, it is pointless to use span. | |||
// I am not sure if it's possible to change CreateFile's param to ROS<char> and avoid all these allocations. |
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.
Can we also follow-up to address this comment? If we can save allocations by marshaling a span instead of creating a string to then pass down, we should. You can't today pass a span directly to a DllImport method, but you can manually pin it and pass in the pointer, which is exactly what the runtime does with string.
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.
Will address this in a separate PR in order to get this in before the preview7 snap, thanks.
Motivated by #55664. When I was testing that PR, I noticed that I was getting ACCESS DENIED errors sporadically, here's the callstack:
I suspect is because of the following (even though I am getting the error when calling
CreateFileW
):runtime/src/libraries/Common/src/System/IO/FileSystem.Attributes.Windows.cs
Lines 73 to 76 in 44f7103
I wasn't able to create a unit case that consistently could hit this issue but by always returning
null
when theLinkTarget
property hits an error, we can mitigate the issue.In addition, this can make developer's life easier by not being afraid of such property breaking their app.
This also grants us parity with the Unix implementation.