0

I'm getting DELETE PENDING errors intermittently when my program deletes a file and then quickly thereafter creates a new file with the same path as the deleted file. In the Dyalog APL session window, it's reported as FILE ACCESS ERROR. I can re-create the error with Dyalog APL 16.0.35389.0 32 Classic on Windows Server 2012 R2 running on VMWare, but not on a bare-metal Windows 10 install. Here's a minimal code example that triggers the error:

:Namespace DeletePending
    ∇ main nTimes;filename;i
      :For i :In ⍳nTimes
          filename←'c:\tmp\delete_pending_dummy.txt'
          (⊂'one' 'two')⎕NPUT filename 1
          filename ⎕NERASE filename ⎕NTIE 0
      :EndFor
    ∇
:EndNamespace

Attached is a screenshot showing the DELETE PENDING error in procmon (Sysinterals).

enter image description here

On my VMWare Windows install, I need to run at least 100 iterations of the loop in the main function (see the DeletePending namespace script above) to trigger the error. As far as I can tell, I'm using ⎕NPUT and ⎕NERASE correctly -- can someone tell me what's wrong?

What I've tried already (summary): creating and erasing a file in a loop, single thread; did not expect intermittent FILE ACCESS ERROR.

  • 1
    [`DeleteFile`](https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-deletefile): *"The `DeleteFile` function marks a file for deletion on close. Therefore, the file deletion does not occur until the last handle to the file is closed. Subsequent calls to `CreateFile` to open the file fail with `ERROR_ACCESS_DENIED`."* That last open handle could be held by your application, or someone else. – IInspectable Feb 03 '23 at 18:37
  • Does it also happen if you remove the `⎕NERASE` line so `⎕NPUT` will attempt to overwrite the file? – Adám Feb 05 '23 at 07:35

1 Answers1

2

This seems to be a known issue C++/Win32: How to wait for a pending delete to complete. I am not sure there is much we (Dyalog) can do about it.

Morten Kromberg
  • 643
  • 5
  • 5