Skip to content

std.fs: deleteTree in dir with open file hangs in loop #19233

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

Closed
ianic opened this issue Mar 9, 2024 · 2 comments
Closed

std.fs: deleteTree in dir with open file hangs in loop #19233

ianic opened this issue Mar 9, 2024 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@ianic
Copy link
Contributor

ianic commented Mar 9, 2024

Zig Version

0.12.0-dev.1800+559e216f3

Steps to Reproduce and Observed Behavior

This test fails on Windows when run with -target aarch64-windows-gnu on other platforms and on Windows without target flag passes.

Created file is not closed and then in tmp.cleanup() deleteTree loops in trying to delete that file.

Closing created file makes test pass.
Removing line tmp.dir.close() also makes test pass without closing file.

test "not closing file" {
    var tmp = std.testing.tmpDir(.{});

    // This file is not closed !!!
    _ = try tmp.dir.createFile("file1", .{ .exclusive = true });

    // Next lines are from tmp.cleanup();
    tmp.dir.close();
    // This produces endless loop
    tmp.parent_dir.deleteTree(&tmp.sub_path) catch {};
    tmp.parent_dir.close();
}

Expected Behavior

deleteTree should return an error instead of trying forever to delete the same file.

@ianic ianic added the bug Observed behavior contradicts documented or intended behavior label Mar 9, 2024
@ianic
Copy link
Contributor Author

ianic commented Mar 9, 2024

When run with -target aarch64-windows-gnu it reports minimal windows version WindowsVersion.win8_1 without flag it is WindowsVersion.win10_fe. That makes difference here

Without entering that 'Deletion with posix semantics' deleteTree loops:

@squeek502
Copy link
Collaborator

squeek502 commented Mar 10, 2024

Duplicate of #15465. Would be fixed by #15467 but a different approach was requested.

EDIT: The minimum version when targeting aarch64-windows-gnu might be a separate possible bug, though.

@squeek502 squeek502 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants