Relax LinkTarget so it always returns null when steps on an error#55668
Relax LinkTarget so it always returns null when steps on an error#55668jozkee merged 1 commit intodotnet:mainfrom
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 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.
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.
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
nullwhen theLinkTargetproperty 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.