-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
unhandled NTSTATUS: DELETE_PENDING in std.os.windows.DeleteFile #6452
Comments
The orange site suggests that the file you were trying to delete was already queued for deletion, but something else (indexer, AV, the very same Zig process maybe) was still keeping an open handle to it. This means the delete operation is extremely platform-dependent and, on Windows at least, it may succeed and leave the file behind. In #6397 @kubkon suggested to follow the ReactOS (and hopefully the Windows libc) behaviour by using |
I'll be happy to take a look but first I really want to have the first working prototype of MachO linker done (without debug info, etc., but something that will not get immediately killed by macOS due to missing dyld info, etc.). Alternatively, if anyone is eager to have a look I'll be happy to mentor! EDIT: Oh, I forgot to mention that I agree with @LemonBoy in that we should definitely investigate the approach taken by ReactOS, and see if it helps out. In the meantime @andrewrk, if this bug will slow you down, we can revert the offending commits. |
BTW, the CI failure on Win with a cryptic name of |
No problem @kubkon - what do you suggest we do to get master branch passing in the meantime? We'll need that to be green so that I can merge #6250 today, and then your macho code will go on top of that
Where are you seeing this? |
I suggest we revert the offending commit for the time being -> #6462.
Oh, in our CI. For instance see CI#1 or CI#2. Both jobs are from today. I'm wondering if we have perhaps reached the Azure mem limit on Windows and hence the LLVM OOM. |
That is entirely possible you can see the rss has been steadily growing of the std lib tests. I think it might be time to start moving some std lib API to the std lib |
See also this from #5537 (comment):
The relevant FileDispositionInformation info from section 4.3.2 (page 33):
|
I recently ran into this issue wheren I leaked file handles, resulting in a delete pending error when trying to create a new file in the same location. The delete then did go through when the program closed, with it all happening quick enough for me not to be sure what is going on. Getting Leaking file handles generally seems to currently be a problem that can silently exist for a while (especially on some platforms) before you suffer the consequences for it in an unexpected place. Would be it be worth creating an issue for this problem specifically and trying to find a solution for making the default debugging experience for those kinds of issues a lot more friendly? |
Also for reference, here is a repro case for this specific problem on Windows: const std = @import("std");
const fs = std.fs;
pub fn main() anyerror!void {
var test_src_dir = try fs.cwd().openDir("", .{});
defer test_src_dir.close();
{
const test_file_handle = try test_src_dir.createFile("test.txt", .{});
test_file_handle.close();
}
{
const test_file_handle = try test_src_dir.openFile("test.txt", .{ .mode = .read_only });
_ = test_file_handle; // leak file handle, do not close!
try test_src_dir.deleteFile("test.txt"); // this will queue a pending deletion
}
{
// Returns error.Unexpected NTSTATUS=0xc0000056, as file handle leaked above is keeping old test.txt alive.
const test_file_handle = try test_src_dir.openFile("test.txt", .{ .mode = .read_only });
test_file_handle.close();
}
} |
I think we should figure out how to avoid this problem altogether rather than figuring out how to better flag that to the user. Is this something you'd like to look into perhaps? |
What do we want to happen when the user deletes a file without closing the file handle to it elsewhere? On Linux this issue was just silently ignored, do we want that? Becuase there seems to be a genuine user error there. Do we want the system to immediately error on trying to delete that file? Even on Linux? I'm not sure I have the answers to those questions - but a consistent experience is probably desirable across platforms. I would be happy to look into implementing any solution, but I'm not really sure what an appropriate solution would look like. EDIT: Actually in the short term I'm going to focus on other problems, because I do want to see zar through to completion ASAP, and I have limited time as is. But I will keep an eye on this issue and might swing back around to it later. |
For Windows, I'd look into Wine and ReactOS to see how they flag it and handle it. I have very little experience with actually using this API, and my first question would be: how do you normally handle this on Windows? What is the best practice wrt to file deletion on Windows? And so on. Another thing to consider, if the API is customisable enough, why not expose it in such a way so that the user of |
Same - and I think the investigations required to get this right are probably beyond my bandwidth right now. There's also multiple aspects to this problem. Because on one hand - what do you expect as a consumer/user of I think it comes to this example: |
For |
InKryption mentioned on Discord seeing some discussion about adding some debug state info for catching this stuff as well in a PR somewhere, so just mentioning that here at least to remind myself to try and find it and link it here. |
Haven't tried the reproduction in #6452 (comment) to see how it behaves, but it's worth noting that the behavior here has changed after #15316:
|
Should be fixed in PR #15501. Can be closed once Windows 10 SP1 is mandatory/WIndows 10 support is dropped with known shortcoming for non-ntfs systems. |
cc @kubkon
I'm not sure what the minimal repro is. This happened when I pulled latest master and ran the tests on Windows.
So the question is what do we do here?
The text was updated successfully, but these errors were encountered: