perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

Win32 stat() didn't handle AF_UNIX socket files

Open tonycoz opened this issue 3 years ago • 6 comments

Unfortunately both symbolic links and sockets can only be "statted" by opening with FILE_FLAG_OPEN_REPARSE_POINT which obviously doesn't follow symbolic links.

So to find if a chain of symbolic links points to a socket, is a broken chain, or loops, we need to follow the chain ourselves.

Fixes #20204

tonycoz avatar Sep 08 '22 08:09 tonycoz

Just a small heads up: I'm planning on doing some testing with this and some reviewing;

(so if possible: wait with merging until I had a chance to test/review)

bram-perl avatar Sep 08 '22 15:09 bram-perl

(so if possible: wait with merging until I had a chance to test/review)

That's no problem.

One test is failing, though I don't see why yet.

tonycoz avatar Sep 12 '22 01:09 tonycoz

One test is failing, though I don't see why yet.

It succeeds sometimes, but mostly fails. I haven't managed to get it to fail locally, and DrMemory (like valgrind) isn't showing anything relevant that I can see.

tonycoz avatar Sep 12 '22 05:09 tonycoz

It succeeds sometimes, but mostly fails.

Or it was, I can't get it to fail in CI at all now.

tonycoz avatar Sep 13 '22 22:09 tonycoz

FWIW, this 20204-stat-socket branch is fine for me when I build it on Windows 11 using gcc-12, where _WIN32_WINNT is 0x0a00 - though some of the TODO tests fail, and the only archtype I've tested is MSWin32-x64-multi-thread.

With the same archtype and same compiler on Windows 7, t/win32/stat.t doesn't run to completion. When run outside the Test::Harness, it terminates with:

....
ok 46 - filename '"' shouldn't exist
ok 47 # skip Cannot create unix socket
Label not found for "last SKIP" at ./test.pl line 535.

Something awry with the SKIP construction ? It also fails some TODO tests.

Of course, there's a couple of questionable practices being undertaken on Windows 7:

  1. AIUI, Windows 7 is technically not supported any more;
  2. Using a compiler that has _WIN32_WINNT set to 0xa00 (Windows 10) on a Windows 7 machine seems a bit dubious.

But this has not been a problem before with gcc-12 builds of perl on Windows 7 - so long as optimization is set to -Os (which I think has just recently become the default optimization setting in blead's win32/GNUmakefile).

Cheers, Rob

sisyphus avatar Sep 15 '22 04:09 sisyphus

The failing TODO tests are for bugs that had been reported against Win32 stat() before I re-worked it, unfortunately they seem to be Windows limits (or bugs, I guess).

tonycoz avatar Sep 15 '22 04:09 tonycoz