Skip to content
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

CreateSymbolicLink PInvoke retval must be marshalled as U1 #69150

Merged
merged 2 commits into from
May 10, 2022

Conversation

jozkee
Copy link
Member

@jozkee jozkee commented May 10, 2022

Fixes #62975. Silent failures were caused by incorrect marshalling, CreateSymbolicLinkW returns BOOLEAN, which is 1 byte, as opposed to BOOL, which is 4 bytes.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost assigned jozkee May 10, 2022
@ghost
Copy link

ghost commented May 10, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #62975. Silent failures were caused by incorrect marshalling, CreateSymbolicLinkW returns BOOLEAN, which is 1 byte, as opposed to BOOL, which is 4 bytes.

Author: Jozkee
Assignees: Jozkee
Labels:

area-System.IO

Milestone: -

@jozkee jozkee added this to the 7.0.0 milestone May 10, 2022
Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be ported back to .NET 6?

@stephentoub stephentoub merged commit 6d23405 into dotnet:main May 10, 2022
@jozkee
Copy link
Member Author

jozkee commented May 11, 2022

@stephentoub there's a reasonable workaround, that is, checking if the link does exists after calling the create symlink method.

@jozkee jozkee deleted the symlink_marshalas branch May 11, 2022 03:13
@ghost ghost locked as resolved and limited conversation to collaborators Jun 10, 2022
@jozkee
Copy link
Member Author

jozkee commented Jul 28, 2022

/backport to release/6.0

@dotnet dotnet unlocked this conversation Jul 28, 2022
@jozkee
Copy link
Member Author

jozkee commented Jul 28, 2022

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/2750562888

@github-actions
Copy link
Contributor

@jozkee backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: CreateSymbolicLink PInvoke retval must be marshalled as U1
Using index info to reconstruct a base tree...
M	src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs
CONFLICT (content): Merge conflict in src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 CreateSymbolicLink PInvoke retval must be marshalled as U1
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

jozkee added a commit to jozkee/runtime that referenced this pull request Jul 28, 2022
)

* CreateSymbolicLink PInvoke retval must be marshalled as U1

* Fix redundant invocations of Environment.OSVersion.Version
carlossanlop pushed a commit that referenced this pull request Aug 11, 2022
…73004)

* CreateSymbolicLink PInvoke retval must be marshalled as U1

* Fix redundant invocations of Environment.OSVersion.Version
@ghost ghost locked as resolved and limited conversation to collaborators Aug 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating symbolic links without developer mode or elevation fails silently
4 participants