On Thu, 8 Apr 2021, Martin Storsjö wrote:

This used to be an issue with msvcrt.dll too, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33281. However, when I try out your test snippet (extended to test the directory both with and without a trailing slash, and with a regular file) I can't reproduce the issue with access() on msvcrt.dll on Vista, as reported there. Maybe Microsoft reverted the change there to keep things from breaking?

I can reproduce the issue with UCRT though. (I also ran into this at some point when I crosscompiled a GCC, where I had managed to miss the GCC access() workaround - I presume I built GCC with UCRT at the time.)

As for how to fix it, see in particular https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33281#c11. Defining X_OK to zero is told to break some codepaths somewhere (that expect it to have a nonzero value).

I guess the least risky solution would be to enable the "__USE_MINGW_ACCESS" codepath unconditionally if using UCRT - what do you think?

(One could also consider to change the implementation of __mingw_access to just strip out the X_OK bit and call the CRT's real _access function, instead of reimplementing it with a call to GetFileAttributesA.)

This discussion never completed here...

Do you agree that we should define __USE_MINGW_ACCESS implicitly when targeting UCRT, as UCRT's access() errors out on X_OK? Msvcrt's access() used to have the same behaviour at some point (in early Vista, judging from the bug report above), but the behaviour there seems to have been reverted (in current installs of Vista and newer major versions too) so that it ignores the bit we set for X_OK in practice, as it did on XP.

It hides a behaviour compared to the actual CRT (which can be detrimental for code portability to MSVC), but as MSVC and upstream UCRT itself doesn't even have X_OK, I think it should be fine.

// Martin

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to