[PATCH] D83834: Add test utility 'split-file'
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 10 14:36:36 PDT 2020
MaskRay added a comment.
In D83834#2208107 <https://reviews.llvm.org/D83834#2208107>, @ro wrote:
> In D83834#2208059 <https://reviews.llvm.org/D83834#2208059>, @MaskRay wrote:
>
>>
>
>
>
>> @ro Can you set a breakpoint while running split-file, checking whether split-file can delete an existing file and replace it with a directory on Solaris?
>> This behavior is intentionally added to support changing `%t` from a file to a directory. It appears to work well on macOS, Linux and Windows.
>
> Here's what I found: the failing call to `split-file` is like this:
>
> ./bin/split-file --no-leading-lines /vol/llvm/src/llvm-project/local/llvm/test/tools/split-file/empty.test /var/llvm/local-sparcv9-A/test/tools/split-file/Output/empty.test.tmp
>
> Running under `truss` shows
>
> 19028: fstatat(AT_FDCWD, "/var/llvm/local-sparcv9-A/test/tools/split-file/Output/empty.test.tmp", 0xFFFFFFFF7FFFE380, AT_SYMLINK_NOFOLLOW) = 0
> 19028: d=0x0000010600010012 i=212407 m=0042750 l=2 u=2110 g=4620 sz=3
> 19028: at = Aug 10 11:21:41 MEST 2020 [ 1597051301.681593645 ]
> 19028: mt = Aug 10 01:46:42 MEST 2020 [ 1597016802.271083280 ]
> 19028: ct = Aug 10 01:46:42 MEST 2020 [ 1597016802.271083280 ]
> 19028: bsz=512 blks=3 fs=zfs
> 19028: unlinkat(AT_FDCWD, "/var/llvm/local-sparcv9-A/test/tools/split-file/Output/empty.test.tmp", AT_REMOVEDIR) Err#17 EEXIST
>
> i.e. it tries to remove a directory. However, this cannot work since the directory in question isn't empty:
>
> $ ls -la /var/llvm/local-sparcv9-A/test/tools/split-file/Output/empty.test.tmp
> total 4
> drwxr-s--- 2 ro gcc 3 Aug 10 01:46 ./
> drwxr-sr-x 5 ro gcc 11 Aug 10 18:32 ../
> -rw-r--r-- 1 ro gcc 0 Aug 10 01:46 empty
>
> When I run `split-file` in `gdb` with a breakpoint in `rmdir`, I get
>
> #0 0xffffffff7eeb7388 in rmdir () from /lib/64/libc.so.1
> #1 0xffffffff7ee2c47c in remove () from /lib/64/libc.so.1
> #2 0x000000010025069c in llvm::sys::fs::remove (path=...,
> IgnoreNonExisting=true)
> at /vol/llvm/src/llvm-project/local/llvm/lib/Support/Unix/Path.inc:442
> #3 0x00000001001821ac in main (argc=4, argv=0xffffffff7fffeb38)
> at /vol/llvm/src/llvm-project/local/llvm/tools/split-file/split-file.cpp:168
>
> So `llvm::sys::fs::remove` tries to call `::remove` on a non-empty directory, while the man page clearly states:
>
> The remove() function causes the file or empty directory whose name is
> the string pointed to by path to be no longer accessible by that name.
> A subsequent attempt to open that file using that name will fail,
> unless the file is created anew.
>
> For files, remove() is identical to unlink(). For directories, remove()
> is identical to rmdir().
>
> and in turn `rmdir(2)` says
>
> The rmdir() function removes the directory named by the path name
> pointed to by path. The directory must not have any entries other than
> "." and "..".
>
> This just cannot work!
std::errc::directory_not_empty is intentionally excluded. What error code is it on Solaris?
if (std::error_code ec = sys::fs::remove(output, /*IgnoreNonExisting=*/true))
if (ec.value() != static_cast<int>(std::errc::directory_not_empty))
fatal(output, ec.message());
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83834/new/
https://reviews.llvm.org/D83834
More information about the llvm-commits
mailing list