Skip to content

Windows' symlink_junction_inner mysteriously fails #107884

Description

@ChrisDenton

I think symlink_junction_inner sometimes isn't writing to the buffer properly which can cause the DeviceIoControl to fail and thus tests that use it. This function isn't great and is only used in tests. I can reproduce this consistently locally on current master but in CI most PRs seem to test ok (though not all).

I've not really investigated yet but on a hunch I added the following which seems to fix it locally, I don't know why or if it's a fluke:

diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs
index 37809803828..d7f1a44bdf4 100644
--- a/library/std/src/sys/windows/fs.rs
+++ b/library/std/src/sys/windows/fs.rs
@@ -1409,6 +1409,8 @@ fn symlink_junction_inner(original: &Path, junction: &Path) -> io::Result<()> {
         (*db).ReparseTargetLength = ((i - 1) * 2) as c::WORD;
         (*db).ReparseDataLength = (*db).ReparseTargetLength as c::DWORD + 12;

+        crate::hint::black_box(slice::from_raw_parts(buf, i));
+
         let mut ret = 0;
         cvt(c::DeviceIoControl(
             h as *mut _,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions