git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/2] compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 13, 2025, 14:17 UTC
Message-ID
<20250313-b4-pks-mingw-lockfile-flake-v1-0-bc5d3e70f516@pks.im>
Hi,

I finally found some time to have a look at why t0610 is failing regularly in MinGW. As it turns out the root cause is our emulation of open(3p): when trying to open a file with `_wopen(..., O_CREAT|O_EXCL)` the call fails in case another process has marked the same file for deletion via `DeleteFileW()`. This gets triggered by t0610 because we race around locking the reftable stack and thus causes the failure.

The fix is simple: we get `ERROR_ACCESS_DENIED` in this situation, so instead of translating that error to `EACCESS` we translate it to `EEXIST`. This fixes the flake on my machine, but as usual when it comes to Windows I would very much like to ask those in the know to point out any obvious mistakes I did.

The other patch is a while-at-it patch that I was wondering about while debugging the issue. It's not needed and I'm happy to drop it if you don't think we should include it.

Thanks!
Patrick
---
Patrick Steinhardt (2):
      compat/mingw: handle O_CLOEXEC in `mingw_open_existing()`
      compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`
 compat/mingw.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

--- base-commit: 4b68faf6b93311254efad80e554780e372deb42f change-id: 20250313-b4-pks-mingw-lockfile-flake-49dfcce8e7c2

Next: Patrick Steinhardt
Message 1 of 14 in “compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`”
  1. 0/2 compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`Patrick Steinhardt, Mar 13, 2025
  2. 2/2 compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`Patrick Steinhardt, Mar 13, 2025
  3. Junio C HamanoMar 13, 2025
  4. Johannes SchindelinMar 16, 2025
  5. Patrick SteinhardtMar 17, 2025
  6. 1/2 compat/mingw: handle O_CLOEXEC in `mingw_open_existing()`Patrick Steinhardt, Mar 13, 2025
  7. Junio C HamanoMar 13, 2025
  8. 0/2 compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`Patrick Steinhardt, Mar 20, 2025
  9. 1/2 meson: fix compat sources when compiling with MSVCPatrick Steinhardt, Mar 20, 2025
  10. 2/2 compat/mingw: fix EACCESS when opening files with `O_CREAT | O_EXCL`Patrick Steinhardt, Mar 20, 2025
  11. Johannes SchindelinMar 26, 2025
  12. Patrick SteinhardtMar 28, 2025
  13. Johannes SchindelinMar 28, 2025
  14. Patrick SteinhardtMar 31, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.